From 69c9a9cb62391be4de4cfebf70c1dd9dea2b22bd Mon Sep 17 00:00:00 2001 From: jolheiser Date: Wed, 20 Dec 2023 17:00:48 -0600 Subject: [PATCH] chore: generic flake Signed-off-by: jolheiser --- README.md | 6 +++--- template/flake.nix | 42 ++++++++++++++++++++++++++++++++---------- tmpl.yaml | 13 +++++++++++++ 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f20cea8..fe8dd91 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# devflake +# flake -Create a simple `flake.nix` for `nix develop` +Create a simple `flake.nix` for nix. ## License -[MIT](LICENSE) \ No newline at end of file +[MIT](LICENSE) diff --git a/template/flake.nix b/template/flake.nix index 80eaa09..5f5ac8a 100644 --- a/template/flake.nix +++ b/template/flake.nix @@ -1,25 +1,47 @@ { - inputs = { - nixpkgs.url = "github:nixos/nixpkgs{{if unstable}}/nixpkgs-unstable{{end}}"; - flake-utils.url = "github:numtide/flake-utils"; - }; + description = "{{description}}"; + + inputs.nixpkgs.url = "github:nixos/nixpkgs{{if unstable}}/nixpkgs-unstable{{end}}"; outputs = { self, - flake-utils, nixpkgs, - }: - flake-utils.lib.eachDefaultSystem ( + }: let + systems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ]; + in + builtins.map ( system: let pkgs = nixpkgs.legacyPackages.${system}; in { - devShells.default = pkgs.mkShell { + {{if pname}} + packages.${system}.default = pkgs.buildGoModule { + pname = {{pname}}; + version = {{version}}; + src = ./.; + vendorHash = ""; + meta = with pkgs.lib; { + description = "{{description}}"; + homepage = "{{url}}"; + maintainers = with maintainers; [jolheiser]; + mainProgram = "{{pname}}"; + }; + }; + {{end}} + {{if packages}} + devShells.${system}.default = pkgs.mkShell { nativeBuildInputs = with pkgs; [ {{- range $pkg := (splitList "\n" packages)}} {{trim $pkg}} {{- end}} ]; }; + {{end}} } - ); -} \ No newline at end of file + ) + systems; +} diff --git a/tmpl.yaml b/tmpl.yaml index 965a5d6..7ae4c08 100644 --- a/tmpl.yaml +++ b/tmpl.yaml @@ -2,6 +2,19 @@ prompts: - id: unstable label: Use unstable type: confirm + - id: pname + label: pname + help: Program name + type: input + - id: version + label: Version + type: input + - id: description + label: Description + type: multi + - id: url + label: Project URL + type: input - id: packages label: Packages help: nixpkgs, one on each line