diff --git a/README.md b/README.md index b55046e0..0c3e1fc0 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ ## Table of Contents - [📦 Installation](#-installation) + - [Nix](#nix) - [Homebrew](#homebrew) - [Cargo](#cargo) - [Cargo BInstall](#cargo-binstall) @@ -81,6 +82,14 @@ ## 📦 Installation +### Nix + +This repository is a flake, and can be installed using nix profile: + +``` +nix profile install "github:rossmacarthur/sheldon" +``` + ### Homebrew Sheldon can be installed using Homebrew. diff --git a/docs/src/Installation.md b/docs/src/Installation.md index 88c0e5fb..336d43cf 100644 --- a/docs/src/Installation.md +++ b/docs/src/Installation.md @@ -1,5 +1,13 @@ # 📦 Installation +## Nix + +This repository is a flake, and can be installed using nix profile: + +``` +nix profile install "github:rossmacarthur/sheldon" +``` + ## Homebrew Sheldon can be installed using Homebrew. diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..1261c122 --- /dev/null +++ b/flake.lock @@ -0,0 +1,85 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1717602782, + "narHash": "sha256-pL9jeus5QpX5R+9rsp3hhZ+uplVHscNJh8n8VpqscM0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e8057b67ebf307f01bdcc8fba94d94f75039d1f6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1717640276, + "narHash": "sha256-xtWJuHl0Zq1/pibvU7V8+qad4fcNLP4yerO54nr4Hec=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "96161e19677e2ae639c41147e422da4d6ec48240", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..d5145b7e --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-utils.follows = "flake-utils"; + }; + }; + }; + outputs = { self, nixpkgs, flake-utils, rust-overlay }: + flake-utils.lib.eachDefaultSystem + (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + in + with pkgs; + { + packages.sheldon = pkgs.callPackage ./sheldon.nix { + inherit (pkgs.darwin.apple_sdk.frameworks) Security; + }; + packages.default = self.outputs.packages.${system}.sheldon; + defaultPackage = self.packages.${system}.sheldon; + devShells.default = mkShell { + buildInputs = [ rust-bin.stable.latest.default ]; + }; + } + ); +} diff --git a/sheldon.nix b/sheldon.nix new file mode 100644 index 00000000..86b5aaa5 --- /dev/null +++ b/sheldon.nix @@ -0,0 +1,38 @@ +# Sheldon package definition +# +# This file will be similar to the package definition in nixpkgs: +# https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/sh/sheldon/package.nix +# +# Helpful documentation: https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md +{ + pkgs, + lib, + stdenv, + installShellFiles, + rustPlatform, + Security, +}: +rustPlatform.buildRustPackage { + name = "sheldon"; + + src = lib.cleanSource ./.; + + cargoLock = { + lockFile = ./Cargo.lock; + # Allow dependencies to be fetched from git and avoid having to set the outputHashes manually + allowBuiltinFetchGit = true; + }; + + nativeBuildInputs = [installShellFiles]; + + buildInputs = [ pkgs.openssl pkgs.curl ] ++ lib.optionals stdenv.isDarwin [Security]; + + doCheck = false; + + meta = with lib; { + description = "Fast, configurable, shell plugin manager"; + homepage = "https://github.com/rossmacarthur/sheldon"; + license = licenses.mit; + mainProgram = "sheldon"; + }; +}