Skip to content

Commit

Permalink
build: add flake.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
hallettj committed Feb 25, 2024
1 parent 9d703c6 commit 92856b8
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ yarn-error.log

# Misc
.DS_Store

# Nix & direnv
/.direnv
/result
43 changes: 43 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default";
};

outputs = { self, nixpkgs, systems }:
let
eachSystem = nixpkgs.lib.genAttrs (import systems);
pkgs = eachSystem (system: nixpkgs.legacyPackages.${system});
in
{
packages = eachSystem (system: {
default = pkgs.${system}.callPackage ./git-format-staged.nix { };
});
devShells = eachSystem (system: {
default = pkgs.${system}.mkShell {
nativeBuildInputs = with pkgs.${system}; [
nodejs_18
python3
];
};
});
};
}
18 changes: 18 additions & 0 deletions git-format-staged.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Nix packaging for git-format-staged
{ stdenvNoCC
, python3
}:
let
manifest = builtins.fromJSON (builtins.readFile ./package.json);
in
stdenvNoCC.mkDerivation {
name = "git-format-staged";
version = manifest.version;
src = ./.;
buildInputs = [ python3 ];
installPhase = ''
mkdir -p "$out/bin"
cp "$src/git-format-staged" "$out/bin/"
chmod +x "$out/bin/git-format-staged"
'';
}

0 comments on commit 92856b8

Please sign in to comment.