flake: rework the nixpkgs init code
This commit is contained in:
parent
19bb39a8b4
commit
dfcb303eef
70
flake.nix
70
flake.nix
|
@ -22,6 +22,10 @@
|
|||
(import "${lix-module}/overlay.nix" { inherit lix; })
|
||||
];
|
||||
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
|
||||
libVersionInfoOverlay = import "${nixpkgs}/lib/flake-version-info.nix" nixpkgs;
|
||||
# this is taken from upstream. if upstream changes, the code here needs to be updated to match
|
||||
addLibVersionInfo = lib: lib.extend libVersionInfoOverlay;
|
||||
lib-base = addLibVersionInfo (import "${nixpkgs}/lib");
|
||||
in {
|
||||
# we don't just use nix.registry.whatever.flake = self
|
||||
# the reason for this is to be able to handle a flake.lock containing an entry for this
|
||||
|
@ -42,8 +46,41 @@
|
|||
# the nix path entry for self
|
||||
meta.path-entry = "dragnpkgs-unstable=flake:dragnpkgs-unstable";
|
||||
|
||||
lib = nixpkgs.lib.extend (final: prev: {
|
||||
licenses = prev.licenses // { fyptl = import ./lib/licenses/fyptl.nix; };
|
||||
lib = (lib-base.extend (import ./lib/overlay.nix)).extend (final: prev: {
|
||||
# initializes regular upstream nixpkgs with the given arguments
|
||||
nixpkgs-custom = { system, ... } @ args: (
|
||||
(import "${nixpkgs}" args).extend (final: prev: {
|
||||
lib = addLibVersionInfo prev.lib;
|
||||
})
|
||||
);
|
||||
|
||||
# initializes dragnpkgs with its overlays and default config using the given arguments
|
||||
dragnpkgs-custom = { system, ... } @ args: let
|
||||
unsafeConf = if builtins.hasAttr "extraBuiltins" builtins then (
|
||||
let conf = builtins.extraBuiltins; in
|
||||
if builtins.isAttrs conf then conf else {}
|
||||
) else {};
|
||||
possiblyCommitCrimes =
|
||||
if
|
||||
builtins.hasAttr "dragnpkgs" unsafeConf &&
|
||||
builtins.isAttrs unsafeConf.dragnpkgs &&
|
||||
builtins.hasAttr "possiblyCommitCrimes" unsafeConf.dragnpkgs &&
|
||||
builtins.isBool unsafeConf.dragnpkgs.possiblyCommitCrimes
|
||||
then
|
||||
unsafeConf.dragnpkgs.possiblyCommitCrimes
|
||||
else
|
||||
false;
|
||||
in
|
||||
final.nixpkgs-custom (args // {
|
||||
overlays = overlays ++ (args.overlays or []);
|
||||
config = (args.config or {}) // {
|
||||
allowlistedLicenses = (final.optionals
|
||||
possiblyCommitCrimes
|
||||
[ final.licenses.fyptl ]) ++ (args.config.allowlistedLicenses or []);
|
||||
};
|
||||
});
|
||||
|
||||
nixos = import "${nixpkgs}/nixos/lib" { lib = final; };
|
||||
|
||||
nixosSystem = args:
|
||||
import "${nixpkgs}/nixos/lib/eval-config.nix" (
|
||||
|
@ -192,36 +229,9 @@
|
|||
});
|
||||
|
||||
legacyPackages = forAllSystems (system:
|
||||
let
|
||||
unsafeConf = if builtins.hasAttr "extraBuiltins" builtins then (
|
||||
let conf = builtins.extraBuiltins; in
|
||||
if builtins.isAttrs conf then conf else {}
|
||||
) else {};
|
||||
possiblyCommitCrimes =
|
||||
if
|
||||
builtins.hasAttr "dragnpkgs" unsafeConf &&
|
||||
builtins.isAttrs unsafeConf.dragnpkgs &&
|
||||
builtins.hasAttr "possiblyCommitCrimes" unsafeConf.dragnpkgs &&
|
||||
builtins.isBool unsafeConf.dragnpkgs.possiblyCommitCrimes
|
||||
then
|
||||
unsafeConf.dragnpkgs.possiblyCommitCrimes
|
||||
else
|
||||
false;
|
||||
in
|
||||
nixpkgs.legacyPackages.${system}.appendOverlays (overlays ++
|
||||
[(final: prev: {
|
||||
stdenv = prev.stdenv.override {
|
||||
config = prev.config // {
|
||||
allowlistedLicenses = final.lib.optionals
|
||||
possiblyCommitCrimes
|
||||
[ final.lib.licenses.fyptl ];
|
||||
};
|
||||
};
|
||||
})])
|
||||
self.lib.dragnpkgs-custom { inherit system; }
|
||||
);
|
||||
|
||||
nixosModules = nixpkgs.nixosModules;
|
||||
|
||||
templates = {
|
||||
default = {
|
||||
path = ./templates/default;
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
final: prev: {
|
||||
licenses = prev.licenses // { fyptl = import ./licenses/fyptl.nix; };
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
final: prev: {
|
||||
lib = prev.lib.extend (lfinal: lprev: {
|
||||
licenses = lprev.licenses // { fyptl = import ./lib/licenses/fyptl.nix; };
|
||||
});
|
||||
lib = prev.lib.extend (import ./lib/overlay.nix);
|
||||
|
||||
fetchFromSteam = prev.callPackage ./lib/fetchsteam {};
|
||||
fetchb4 = prev.callPackage ./lib/fetchb4 {};
|
||||
|
|
Loading…
Reference in New Issue