This commit is contained in:
Félix Baylac Jacqué 2023-04-17 16:53:17 +02:00
parent 57d071645f
commit 4055d72892
4 changed files with 75 additions and 11 deletions

View File

@ -1,5 +1,22 @@
{
"nodes": {
"harmonia": {
"flake": false,
"locked": {
"lastModified": 1680542005,
"narHash": "sha256-fT9CJ/WAH5ESU4Ja062U/qNWDmhEfHI1XctnFjgBJ+A=",
"owner": "nix-community",
"repo": "harmonia",
"rev": "849a845c327ffb8fcc3322176479f6909f7a51a1",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "master",
"repo": "harmonia",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1681389457,
@ -16,6 +33,7 @@
},
"root": {
"inputs": {
"harmonia": "harmonia",
"nixpkgs": "nixpkgs"
}
}

View File

@ -1,14 +1,29 @@
{
description = "Kefla POC";
outputs = { self, nixpkgs }:
inputs = {
harmonia = {
type = "github";
owner = "nix-community";
repo = "harmonia";
ref = "master";
flake = false;
};
};
outputs = { self, nixpkgs, ... }@inputs:
let
kefla = import ./kefla nixpkgs;
kefla = import ./kefla inputs;
in {
packages = kefla {
# available on all achs
package-all = ./package-all.nix;
# Darwin-only
package-darwin = ./package-darwin.nix;
# Linux
package-linux = ./package-linux.nix;
# Uses meta
package-flake-meta = ./package-flake-meta.nix;
};
};
}

View File

@ -1,10 +1,10 @@
nixpkgs:
inputs:
let
dummyPkgs = import nixpkgs { system = "x86_64-linux"; };
dummyPkgs = import inputs.nixpkgs { system = "x86_64-linux"; };
lib = dummyPkgs.lib;
in rec {
# Collects all the supported for drv leveraging the meta.platforms
# Nixpkgs attribute.
# Collects all the supported systems for drv leveraging the
# meta.platforms Nixpkgs attribute.
#
# We callPackage the derivation with a dummy Nixpkgs x86_64
# instance, regardless of the underlying arch. It doesn't matter
@ -37,16 +37,15 @@ in rec {
let
injectPlatformCallPackage = { attrs, platform }:
let
pkgs = import nixpkgs { system = platform; };
callPackage = pkgs.lib.callPackageWith pkgs;
in builtins.mapAttrs (_name: value: callPackage value {}) attrs;
pkgs = import inputs.nixpkgs { system = platform; };
in builtins.mapAttrs (_name: value: pkgs.callPackage value { flakeMeta.inputs = inputs;}) attrs;
in builtins.mapAttrs (name: value:
injectPlatformCallPackage { attrs = value; platform = name; }) packages;
#
kefla = packagesOutput:
let
# We first generate the packages output like in its final form. We
# just lack the callPackage on the derivation path.
packagesWithoutCallPackage = lib.foldlAttrs
(acc: name: path:
let

32
package-flake-meta.nix Normal file
View File

@ -0,0 +1,32 @@
{ lib
, stdenv
, fetchurl
, flakeMeta
}:
stdenv.mkDerivation (finalAttrs: {
pname = "hello";
version = "2.12.1";
src = fetchurl {
url = "mirror://gnu/hello/hello-${finalAttrs.version}.tar.gz";
sha256 = "sha256-jZkUKv2SV28wsM18tCqNxoCZmLxdYH2Idh9RLibH2yA=";
};
doCheck = true;
nativeBuildInputs = [ flakeMeta.inputs.harmonia ];
meta = with lib; {
description = "A program that produces a familiar, friendly greeting";
longDescription = ''
GNU Hello is a program that prints "Hello, world!" when you run it.
It is fully customizable.
'';
homepage = "https://www.gnu.org/software/hello/manual/";
changelog = "https://git.savannah.gnu.org/cgit/hello.git/plain/NEWS?h=v${finalAttrs.version}";
license = licenses.gpl3Plus;
maintainers = [ maintainers.eelco ];
platforms = platforms.all;
};
})