From ec54b5f54b600320480df055d3288a4e7a9f0cbc Mon Sep 17 00:00:00 2001 From: nebunebu Date: Sat, 3 Aug 2024 20:04:01 -0400 Subject: [PATCH 1/4] add nix flake --- README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++--------- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 39 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/README.md b/README.md index a563e8e..8d47155 100644 --- a/README.md +++ b/README.md @@ -39,19 +39,56 @@ Personally, I found the output from `git log --graph` difficult to read, even wi ### Cargo ``` -$ cargo install --locked serie +cargo install --locked serie ``` ### Arch Linux ``` -$ pacman -S serie +pacman -S serie ``` ### Homebrew (macOS) ``` -$ brew install lusingander/tap/serie +brew install lusingander/tap/serie +``` + +### Nix + +#### Running with Nix + +```sh +$ nix run "github:lusingander/serie" --extra-experimental-features "nix-command +flakes" +``` + +#### Installation with Nix + +Add to flake inputs + +```nix +inputs.serie.url = "github:lusingander/serie"; +``` + +As a home-manager package, + +```nix +{ inputs, pkgs, ... }: + +{ + home.packages = [ inputs.serie.packages.${pkgs.system}.default ]; +} +``` + +As a nix package, + +```nix +{ inputs, pkgs, ... }: + +{ + home.packages = [ inputs.serie.packages.${pkgs.system}.default ]; +} ``` ### Downloading binary @@ -63,10 +100,10 @@ You can download pre-compiled binaries from [releases](https://github.com/lusing If you want to check the latest development version, build from source: ``` -$ git clone https://github.com/lusingander/serie.git -$ cd serie -$ cargo build --release -$ ./target/release/serie +git clone https://github.com/lusingander/serie.git +cd serie +cargo build --release +./target/release/serie ``` > [!NOTE] @@ -79,8 +116,8 @@ $ ./target/release/serie Run `serie` in the directory where your git repository exists. ``` -$ cd -$ serie +cd +serie ``` ### Options diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d56370f --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1722421184, + "narHash": "sha256-/DJBI6trCeVnasdjUo9pbnodCLZcFqnVZiLUfqLH4jA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9f918d616c5321ad374ae6cb5ea89c9e04bf3e58", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..781773d --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + inputs.nixpkgs = { + type = "github"; + owner = "NixOS"; + repo = "nixpkgs"; + ref = "nixos-unstable"; + }; + + outputs = + { nixpkgs, self, ... }: + let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + in + { + packages = forAllSystems ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + serie = pkgs.rustPlatform.buildRustPackage { + pname = (pkgs.lib.importTOML (./Cargo.toml)).package.name; + version = (pkgs.lib.importTOML (./Cargo.toml)).package.version; + src = ./.; + cargoLock.lockFile = ./Cargo.lock; + meta.mainProgram = "serie"; + nativeBuildInputs = [ pkgs.git ]; + }; + default = self.packages.${system}.serie; + } + ); + }; +} From 6e3cf674640e576330ae14278d84b8413ca37785 Mon Sep 17 00:00:00 2001 From: nebunebu Date: Tue, 13 Aug 2024 16:37:36 -0400 Subject: [PATCH 2/4] add devShell to flake.nix --- flake.nix | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 781773d..a9e2a98 100644 --- a/flake.nix +++ b/flake.nix @@ -6,8 +6,7 @@ ref = "nixos-unstable"; }; - outputs = - { nixpkgs, self, ... }: + outputs = inputs: let supportedSystems = [ "x86_64-linux" @@ -15,13 +14,13 @@ "x86_64-darwin" "aarch64-darwin" ]; - forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + forAllSystems = inputs.nixpkgs.lib.genAttrs supportedSystems; in { packages = forAllSystems ( system: let - pkgs = nixpkgs.legacyPackages.${system}; + pkgs = inputs.nixpkgs.legacyPackages.${system}; in { serie = pkgs.rustPlatform.buildRustPackage { @@ -32,7 +31,23 @@ meta.mainProgram = "serie"; nativeBuildInputs = [ pkgs.git ]; }; - default = self.packages.${system}.serie; + default = inputs.self.packages.${system}.serie; + } + ); + devShells = forAllSystems ( + system: + let + pkgs = inputs.nixpkgs.legacyPackages.${system}; + in + { + default = pkgs.mkShell { + name = "devShell"; + packages = [ + inputs.self.packages.${system}.serie + pkgs.rustfmt + pkgs.rustup + ]; + }; } ); }; From 444952ed2e8d95282c6458d4445a127ff3015fd5 Mon Sep 17 00:00:00 2001 From: nebunebu Date: Fri, 16 Aug 2024 15:37:29 -0400 Subject: [PATCH 3/4] remove rustup from devShell --- flake.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/flake.nix b/flake.nix index a9e2a98..967d2b7 100644 --- a/flake.nix +++ b/flake.nix @@ -45,7 +45,6 @@ packages = [ inputs.self.packages.${system}.serie pkgs.rustfmt - pkgs.rustup ]; }; } From 67e82ab01948c10baf92557bdb44d30f5b81adf7 Mon Sep 17 00:00:00 2001 From: nebunebu Date: Fri, 16 Aug 2024 16:15:11 -0400 Subject: [PATCH 4/4] udpate flake --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index d56370f..5e857ba 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1722421184, - "narHash": "sha256-/DJBI6trCeVnasdjUo9pbnodCLZcFqnVZiLUfqLH4jA=", + "lastModified": 1723637854, + "narHash": "sha256-med8+5DSWa2UnOqtdICndjDAEjxr5D7zaIiK4pn0Q7c=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9f918d616c5321ad374ae6cb5ea89c9e04bf3e58", + "rev": "c3aa7b8938b17aebd2deecf7be0636000d62a2b9", "type": "github" }, "original": {