From 8568a3b3ad0aef00fb3050676b4fdd23ba6d49bf Mon Sep 17 00:00:00 2001 From: jolheiser Date: Sun, 9 Jun 2024 20:59:43 -0500 Subject: [PATCH] feat: nix Signed-off-by: jolheiser --- .gitignore | 2 ++ flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ go.mod.sri | 1 + 4 files changed, 81 insertions(+) create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 go.mod.sri diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..38d8daa --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/cfg +result/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..25504b0 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1717786204, + "narHash": "sha256-4q0s6m0GUcN7q+Y2DqD27iLvbcd1G50T2lv08kKxkSI=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "051f920625ab5aabe37c920346e3e69d7d34400e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..0c17f6a --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + description = "cfg"; + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + outputs = { + self, + nixpkgs, + ... + }: let + systems = [ + "aarch64-darwin" + "aarch64-linux" + "x86_64-darwin" + "x86_64-linux" + ]; + inherit (nixpkgs) lib; + forEachSystem = f: (lib.listToAttrs ( + map (system: { + name = system; + value = f { + inherit system; + pkgs = import nixpkgs { + inherit system; + }; + }; + }) + systems + )); + in { + packages = forEachSystem ({ + pkgs, + system, + }: { + default = self.packages.${system}.cfg; + cfg = pkgs.buildGoModule rec { + pname = "cfg"; + version = self.rev or "dev"; + src = pkgs.nix-gitignore.gitignoreSource [] (builtins.path { + name = pname; + path = ./.; + }); + subPackages = ["cmd/cfg"]; + vendorHash = nixpkgs.lib.fileContents ./go.mod.sri; + meta = { + description = "config transpiler"; + homepage = "https://git.jolheiser.com/cfg"; + mainProgram = "cfg"; + }; + }; + }); + }; +} diff --git a/go.mod.sri b/go.mod.sri new file mode 100644 index 0000000..44410ee --- /dev/null +++ b/go.mod.sri @@ -0,0 +1 @@ +sha256-IKdsBsOJ41qh/d2ZxgkY0IihIGieYlTtdHRmFufS+yQ= \ No newline at end of file