Skip to content

Commit

Permalink
add templates
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishrb committed Sep 6, 2024
1 parent 3fd3c5e commit f8d90b5
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
15 changes: 14 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
};

# Programs that can be run by calling this flake
#apps = forAllSystems (system:
apps = forAllSystems (
system:
let
Expand All @@ -134,6 +133,7 @@

});

# Checks for nvim health
checks = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system overlays; };
Expand All @@ -154,5 +154,18 @@
}
);

# Templates for starting other projects quickly
templates = rec {
default = basic;
basic = {
path = ./templates/basic;
description = "Basic program template";
};
python = {
path = ./templates/python;
description = "Python template";
};
};

};
}
7 changes: 7 additions & 0 deletions templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Templates

These are new flakes that can be generated quickly using:

```bash
nix flake init -t github:chrishrb/dotfiles#basic
```
30 changes: 30 additions & 0 deletions templates/basic/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
description = "Basic project";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, ... }@inputs: inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
packages.default = pkgs.mkDerivation {
name = "basic";
src = self;
# buildInputs = with pkgs; [];
buildPhase = ''
echo "Building..."
mkdir -p $out/bin
echo "#!/bin/bash" > $out/bin/hello.sh
echo "echo Hello, world!" >> $out/bin/hello.sh
'';
};

devShells.default = pkgs.mkShell {
# buildInputs = with pkgs; [ ];
};
}
);
}
27 changes: 27 additions & 0 deletions templates/python/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
description = "Python template";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { nixpkgs, self, ... }@inputs: inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
in
{
packages.default = pkgs.python312Packages.buildPythonApplication {
name = "python-cli";
src = self;
buildInputs = with pkgs.python312Packages; [ pip setuptools wheel ];
checkInputs = with pkgs.python312Packages; [ pytest arnparse requests-mock ];
propagatedBuildInputs = with pkgs.python3Packages; [
boto3
requests
urllib3
click
];
};
}
);
}

0 comments on commit f8d90b5

Please sign in to comment.