diff --git a/outputs/default.nix b/outputs/default.nix index e82fb55..2a45066 100644 --- a/outputs/default.nix +++ b/outputs/default.nix @@ -8,5 +8,6 @@ ./pkgs ./images.nix ./devshells + ./templates ]; } diff --git a/outputs/templates/basic/flake.nix b/outputs/templates/basic/flake.nix new file mode 100644 index 0000000..9db2f0c --- /dev/null +++ b/outputs/templates/basic/flake.nix @@ -0,0 +1,15 @@ +{ + description = "Description for the project"; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + systems.url = "github:nix-systems/default-linux"; + }; + + outputs = inputs @ {flake-parts, ...}: + flake-parts.lib.mkFlake {inherit inputs;} { + systems = import inputs.systems; + imports = [./outputs]; + }; +} diff --git a/outputs/templates/basic/outputs/default.nix b/outputs/templates/basic/outputs/default.nix new file mode 100644 index 0000000..ad0ccde --- /dev/null +++ b/outputs/templates/basic/outputs/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./shell.nix + ./pkgs.nix + ]; +} diff --git a/outputs/templates/basic/outputs/pkgs.nix b/outputs/templates/basic/outputs/pkgs.nix new file mode 100644 index 0000000..da50d0e --- /dev/null +++ b/outputs/templates/basic/outputs/pkgs.nix @@ -0,0 +1,18 @@ +{self, ...}: { + perSystem = { + pkgs, + self', + ... + }: { + packages.default = pkgs.stdenvNoCC.mkDerivation { + pname = "my package"; + version = "0.1.0"; + src = "${self}/src"; + nativeBuildInputs = []; + + buildPhase = ""; + dontInstall = true; + }; + apps.default = self'.packages.default; + }; +} diff --git a/outputs/templates/basic/outputs/shell.nix b/outputs/templates/basic/outputs/shell.nix new file mode 100644 index 0000000..97f9514 --- /dev/null +++ b/outputs/templates/basic/outputs/shell.nix @@ -0,0 +1,10 @@ +{ + perSystem = {pkgs, ...}: { + devShells.default = pkgs.mkShellNoCC { + name = "project devshell"; + packages = + builtins.attrValues { + }; + }; + }; +} diff --git a/outputs/templates/default.nix b/outputs/templates/default.nix new file mode 100644 index 0000000..86152ca --- /dev/null +++ b/outputs/templates/default.nix @@ -0,0 +1,12 @@ +{ + flake.templates = { + default = { + path = ./basic; + description = "Default project template"; + }; + go = { + path = ./go; + description = "Basic go template"; + }; + }; +} diff --git a/outputs/templates/go/flake.nix b/outputs/templates/go/flake.nix new file mode 100644 index 0000000..9db2f0c --- /dev/null +++ b/outputs/templates/go/flake.nix @@ -0,0 +1,15 @@ +{ + description = "Description for the project"; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + systems.url = "github:nix-systems/default-linux"; + }; + + outputs = inputs @ {flake-parts, ...}: + flake-parts.lib.mkFlake {inherit inputs;} { + systems = import inputs.systems; + imports = [./outputs]; + }; +} diff --git a/outputs/templates/go/outputs/default.nix b/outputs/templates/go/outputs/default.nix new file mode 100644 index 0000000..ad0ccde --- /dev/null +++ b/outputs/templates/go/outputs/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./shell.nix + ./pkgs.nix + ]; +} diff --git a/outputs/templates/go/outputs/pkgs.nix b/outputs/templates/go/outputs/pkgs.nix new file mode 100644 index 0000000..32ebf2a --- /dev/null +++ b/outputs/templates/go/outputs/pkgs.nix @@ -0,0 +1,20 @@ +{self, ...}: { + perSystem = { + pkgs, + self', + lib, + ... + }: { + packages.default = pkgs.buildGoModule { + pname = "hello"; + version = "0.0.1"; + src = "${self}/src"; + meta.mainProgram = "hello"; + vendorHash = null; + }; + apps.default = { + type = "app"; + program = "${lib.getExe self'.packages.default}"; + }; + }; +} diff --git a/outputs/templates/go/outputs/shell.nix b/outputs/templates/go/outputs/shell.nix new file mode 100644 index 0000000..ccf8508 --- /dev/null +++ b/outputs/templates/go/outputs/shell.nix @@ -0,0 +1,10 @@ +{ + perSystem = {pkgs, ...}: { + devShells.default = pkgs.mkShellNoCC { + name = "project devshell"; + packages = builtins.attrValues { + inherit (pkgs) go gopls gotools go-tools; + }; + }; + }; +}