diff --git a/contrib/nix/flake.nix b/contrib/nix/flake.nix new file mode 100644 index 0000000000..10573a150c --- /dev/null +++ b/contrib/nix/flake.nix @@ -0,0 +1,28 @@ +{ + description = "CFEngine Masterfiles"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + lib = pkgs.lib; + + baseVersion = lib.strings.trim (builtins.readFile ../../.CFVERSION); + shortSha = + if self ? rev then builtins.substring 0 9 self.rev + else if self ? dirtyRev then builtins.substring 0 9 self.dirtyRev + else "unknown0"; + version = "${baseVersion}a.${shortSha}"; + + masterfiles = pkgs.callPackage ./masterfiles.nix { inherit version; }; + in + { + packages.default = masterfiles; + } + ); +} diff --git a/contrib/nix/masterfiles.nix b/contrib/nix/masterfiles.nix new file mode 100644 index 0000000000..4037517b4f --- /dev/null +++ b/contrib/nix/masterfiles.nix @@ -0,0 +1,25 @@ +{ stdenv +, nix-gitignore +, autoreconfHook +, version +}: + +stdenv.mkDerivation { + pname = "cfengine-masterfiles"; + version = version; + + src = ../../.; + + nativeBuildInputs = [ autoreconfHook ]; + + postPatch = '' + echo "${version}" > CFVERSION + ''; + + enableParallelBuilding = true; + + configureFlags = [ + "--without-core" + "--without-enterprise" + ]; +}