From 885ef912b29014bc36be083ab6ef7c84fcfc9f75 Mon Sep 17 00:00:00 2001 From: Piotr Gaczkowski Date: Fri, 7 Jun 2024 09:09:01 +0200 Subject: [PATCH 1/3] Add Nix Flake support --- README.md | 9 ++++++ flake.lock | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 34 +++++++++++++++++++++ sheldon.nix | 38 ++++++++++++++++++++++++ 4 files changed, 166 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 sheldon.nix diff --git a/README.md b/README.md index 5330d78e..d3024195 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/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"; + }; +} From f381fdd9500b28671644a4b28834958e01d2f85b Mon Sep 17 00:00:00 2001 From: Piotr Gaczkowski Date: Sun, 9 Jun 2024 18:13:45 +0200 Subject: [PATCH 2/3] Update docs --- docs/src/Installation.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/src/Installation.md b/docs/src/Installation.md index 88c0e5fb..f5711c79 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. From f7445c75b341883ca8768fa3305ec642bb9d604c Mon Sep 17 00:00:00 2001 From: Ross MacArthur Date: Sun, 9 Jun 2024 18:35:49 +0200 Subject: [PATCH 3/3] Update Installation.md --- docs/src/Installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/Installation.md b/docs/src/Installation.md index f5711c79..336d43cf 100644 --- a/docs/src/Installation.md +++ b/docs/src/Installation.md @@ -1,6 +1,6 @@ # 📦 Installation -### Nix +## Nix This repository is a flake, and can be installed using nix profile: