summaryrefslogtreecommitdiff
path: root/templates/basic/flake.nix
diff options
context:
space:
mode:
authorseth <[email protected]>2023-05-17 02:54:40 -0400
committerseth <[email protected]>2023-05-17 02:54:40 -0400
commit423914276f9623786e1d33e486b26a1406115067 (patch)
tree0e4b9453d7d03343168ed0e1d3a6e380caf3e124 /templates/basic/flake.nix
parente727e435f50027c30d3311020c64ead42c146d66 (diff)
templates: init basic & full
Diffstat (limited to 'templates/basic/flake.nix')
-rw-r--r--templates/basic/flake.nix75
1 files changed, 75 insertions, 0 deletions
diff --git a/templates/basic/flake.nix b/templates/basic/flake.nix
new file mode 100644
index 0000000..2c638b2
--- /dev/null
+++ b/templates/basic/flake.nix
@@ -0,0 +1,75 @@
+{
+ description = "";
+
+ inputs = {
+ nixpkgs.url = "nixpkgs/nixos-unstable";
+ };
+
+ outputs = {
+ self,
+ nixpkgs,
+ ...
+ }: let
+ version = builtins.substring 0 8 self.lastModifiedDate;
+
+ systems = [
+ "x86_64-linux"
+ "aarch64-linux"
+ "x86_64-darwin"
+ "aarch64-darwin"
+ ];
+
+ forAllSystems = nixpkgs.lib.genAttrs systems;
+ nixpkgsFor = forAllSystems (system:
+ import nixpkgs {
+ inherit system;
+ overlays = [self.overlays.default];
+ });
+
+ packageFn = pkgs: let
+ inherit (pkgs.lib) licenses maintainers platforms;
+ in {
+ hello = pkgs.stdenv.mkDerivation rec {
+ pname = "hello";
+ inherit version;
+
+ src = builtins.path {
+ name = "${pname}-src";
+ path = ./.;
+ };
+
+ installPhase = ''
+ echo "hi" > $out
+ '';
+
+ meta = {
+ description = "";
+ homepage = "";
+ license = licenses.mit;
+ maintainers = [maintainers.getchoo];
+ platforms = platforms.linux;
+ };
+ };
+ };
+ in {
+ devShells = forAllSystems (s: let
+ pkgs = nixpkgsFor.${s};
+ inherit (pkgs) mkShell;
+ in {
+ default = mkShell {
+ packages = with pkgs; [
+ bash
+ ];
+ };
+ });
+
+ formatter = forAllSystems (s: nixpkgsFor.${s}.alejandra);
+
+ packages = forAllSystems (s: rec {
+ inherit (nixpkgsFor.${s}) hello;
+ default = hello;
+ });
+
+ overlays.default = final: _: packageFn final;
+ };
+}