Skip to content

Commit

Permalink
feat(templates): nix
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelroses committed Dec 31, 2024
1 parent f8d0857 commit 68ae233
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
5 changes: 5 additions & 0 deletions parts/templates/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@
path = ./rust;
description = "A Rust template";
};

nix = {
path = ./nix;
description = "A Nix template";
};
};
}
22 changes: 22 additions & 0 deletions parts/templates/nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ lib, stdenv }:
stdenv.mkDerivation {
pname = "example-nix";
version = "0.1.0";

src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.intersection (lib.fileset.fromSource (lib.sources.cleanSource ./.)) (
lib.fileset.unions [
# files
]
);
};

meta = {
homepage = "https://github.com/isabelroses/example-nix";
description = "An example Nix project";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ isabelroses ];
mainPackage = "example";
};
}
29 changes: 29 additions & 0 deletions parts/templates/nix/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
description = "Nix Project Template";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
};

outputs =
{ self, nixpkgs }:
let
forAllSystems =
function:
nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (
system: function nixpkgs.legacyPackages.${system}
);
in
{
packages = forAllSystems (pkgs: {
example = pkgs.callPackage ./default.nix { };
default = self.packages.${pkgs.stdenv.hostPlatform.system}.example;
});

devShells = forAllSystems (pkgs: {
default = pkgs.callPackage ./shell.nix { };
});

overlays.default = final: _: { example = final.callPackage ./default.nix { }; };
};
}
10 changes: 10 additions & 0 deletions parts/templates/nix/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
eza,
callPackage,
}:
let
mainPkg = callPackage ./default.nix { };
in
mainPkg.overrideAttrs (oa: {
nativeBuildInputs = [ eza ] ++ (oa.nativeBuildInputs or [ ]);
})

0 comments on commit 68ae233

Please sign in to comment.