Skip to content

Commit

Permalink
flake: allow unfreeRedistributable builds
Browse files Browse the repository at this point in the history
  • Loading branch information
JustTNE committed Oct 2, 2023
1 parent 993e96a commit 922e10d
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 30 deletions.
49 changes: 24 additions & 25 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,39 @@ rec {
};
};

outputs = { nixpkgs, yafas, ... }@inputs: yafas.withAllSystems nixpkgs
(universals: { pkgs, ... }: with universals; {
# Just exposes the packages created by the overlay.
packages =
outputs = { nixpkgs, yafas, ... }@inputs:
let
overlays.default = import ./overlays { flakes = inputs; };
getPackages = pkgs:
let
overlayFinal = pkgs // ourPackages // { callPackage = pkgs.newScope overlayFinal; };
ourPackages = overlays.default overlayFinal pkgs;
in
ourPackages;

# I would prefer if we had something stricter, with attribute alphabetical
# sorting, and optimized for git's diffing. But this is the closer we have.
formatter = pkgs.nixpkgs-fmt;
})
rec {
# To fix `nix show` and FlakeHub
schemas = import ./maintenance/schemas { flakes = inputs; };
in
yafas.withAllSystems nixpkgs
(universals: { pkgs, ... }: with universals; {
# Just exposes the packages created by the overlay.
packages = getPackages pkgs;

# The stars: our overlay and our modules.
overlays.default = import ./overlays { flakes = inputs; };
nixosModules = import ./modules/nixos { flakes = inputs; };
homeManagerModules = import ./modules/home-manager { flakes = inputs; };
# I would prefer if we had something stricter, with attribute alphabetical
# sorting, and optimized for git's diffing. But this is the closer we have.
formatter = pkgs.nixpkgs-fmt;
})
rec {
# To fix `nix show` and FlakeHub
schemas = import ./maintenance/schemas { flakes = inputs; };

# Dev stuff.
devShells = import ./maintenance/dev-shells { flakes = inputs; };
_dev = {
x86_64-linux =
nixpkgs.lib.nixosSystem {
modules = [ nixosModules.default ];
system = "x86_64-linux";
};
inherit nixConfig;
# The stars: our overlay and our modules.
inherit overlays;
nixosModules = import ./modules/nixos { flakes = inputs; };
homeManagerModules = import ./modules/home-manager { flakes = inputs; };

# Dev stuff.
devShells = import ./maintenance/dev-shells { flakes = inputs; };
_dev = import ./maintenance/dev { flakes = inputs; inherit nixConfig getPackages; };
};
};

# Allows the user to use our cache when using `nix run <thisFlake>`.
nixConfig = {
Expand Down
4 changes: 2 additions & 2 deletions maintenance/dev-shells/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
, homeManagerModules ? self.homeManagerModules
, nixpkgs ? flakes.nixpkgs
, home-manager ? flakes.home-manager
, packages ? self.packages
, packages ? self._dev.packages
, self ? flakes.self
, nyxosConfiguration ? self._dev.x86_64-linux
, nyxosConfiguration ? self._dev.system.x86_64-linux
}:

# The following shells are used to help our maintainers and CI/CDs.
Expand Down
22 changes: 22 additions & 0 deletions maintenance/dev/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ flakes, nixConfig, getPackages, self ? flakes.self }: flakes.yafas.withAllSystems { }
(universals: { system, ... }:
let
pkgs = import flakes.nixpkgs {
inherit system;
config = {
allowlistedLicenses = [ flakes.nixpkgs.lib.licenses.unfreeRedistributable ];
nvidia.acceptLicense = true;
};
};
in
with universals; {
packages = getPackages pkgs;
nixpkgs = pkgs;
system = flakes.nixpkgs.lib.nixosSystem {
modules = [ self.nixosModules.default ];
system = "x86_64-linux";
};
})
{
inherit nixConfig;
}
2 changes: 1 addition & 1 deletion maintenance/schemas/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
The `nixosModules` flake output contains the modules and options we support for NixOS setups.
'';
inventory = import ./nixos-modules/inventory.nix {
nyxosConfiguration = self._dev.${baseSystem};
nyxosConfiguration = self._dev.system.${baseSystem};
pkgs = nixpkgs.legacyPackages.${baseSystem};
};
};
Expand Down
3 changes: 2 additions & 1 deletion maintenance/tools/builder/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
, nix
, nyxUtils
, writeShellScriptBin
, hostPlatform
}:
let
Jq = "${jq}/bin/jq";
Expand Down Expand Up @@ -166,7 +167,7 @@ writeShellScriptBin "chaotic-nyx-build" ''
function build() {
_WHAT="''${1:- アンノーン}"
_MAIN_OUT_PATH="''${2:-/dev/null}"
_FULL_TARGETS=("''${_ALL_OUT_KEYS[@]/#/$NYX_SOURCE\#}")
_FULL_TARGETS=("''${_ALL_OUT_KEYS[@]/#/$NYX_SOURCE\#_dev.packages.${hostPlatform.system}.}")
echo -n "* $_WHAT..."
# If NYX_CHANGED_ONLY is set, only build changed derivations
if [ -f filter.txt ] && ! ${Grep} -Pq "^$_WHAT\$" filter.txt; then
Expand Down
4 changes: 3 additions & 1 deletion shared/recursion-helper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ rec {
(if lib.attrsets.isDerivation v then
(if (v.meta.broken or true) then
warnFn fullKey v "marked broken"
else if (v.meta.unfree or true) then
# In case we get issues with custom licenses at a later date or we need to remove nvidia.acceptLicense
# else if (v.meta.unfree or true && !(v.meta.license == lib.licenses.unfreeRedistributable && (!(v ? src) || (builtins.tryEval v.src).success))) then
else if (v.meta.unfree or true && !(v.meta.nyx.bypassLicense or false) && v.meta.license != lib.licenses.unfreeRedistributable) then
warnFn fullKey v "unfree"
else
mapFn fullKey v
Expand Down

0 comments on commit 922e10d

Please sign in to comment.