nixos-configs/lib/flake-lib.nix

91 lines
2.2 KiB
Nix
Raw Normal View History

inputs: rec {
# Import pkgs from a nixpkgs instance
mkPkgs = {
system,
nixpkgs,
cudaSupport ? false,
}:
import nixpkgs {
inherit system;
config = {
allowUnfree = true;
inherit cudaSupport;
};
};
2024-09-22 23:16:10 -04:00
allowModularOverrides = {
cudaSupport ? false,
system,
2024-09-22 23:16:10 -04:00
}: ({config, ...}: let
pkgs = mkPkgs {
inherit system cudaSupport;
inherit (inputs) nixpkgs;
};
2024-09-22 23:16:10 -04:00
inherit (pkgs.lib) composeManyExtensions mkForce;
in {
_module.args.pkgs = mkForce (pkgs.extend (composeManyExtensions config.nixpkgs.overlays));
});
# Default system
mkNixOS = {
extraModules ? [],
cudaSupport ? false,
}:
inputs.nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
2024-09-22 23:16:10 -04:00
specialArgs = inputs;
modules =
[
2024-09-22 23:16:10 -04:00
(allowModularOverrides {inherit system cudaSupport;})
{home-manager.extraSpecialArgs = specialArgs;}
../common
]
++ extraModules;
};
mkNixOnDroid = mods: let
system = "aarch64-linux";
in
inputs.nix-on-droid.lib.nixOnDroidConfiguration rec {
2024-09-22 23:16:10 -04:00
extraSpecialArgs = inputs;
home-manager-path = inputs.home-manager.outPath;
pkgs = mkPkgs {
inherit system;
inherit (inputs) nixpkgs;
};
2024-09-22 23:16:10 -04:00
modules =
[
(allowModularOverrides {inherit system;})
2024-09-22 23:16:10 -04:00
({
config,
lib,
...
}: let
inherit (lib) mkForce mkOption types;
2024-09-22 23:16:10 -04:00
in {
# Adapt NixOnDroid to NixOS options
options.environment = {
variables.FLAKE = mkOption {
type = with types; nullOr str;
};
2024-09-22 23:16:10 -04:00
systemPackages = mkOption {
type = with types; listOf package;
default = [];
};
};
2024-09-22 23:16:10 -04:00
config.environment.packages = config.environment.systemPackages;
# This disables the assertion that fails because of nixpkgs.overlays
config._module.args.isFlake = mkForce false;
})
2024-09-22 23:16:10 -04:00
{home-manager = {inherit extraSpecialArgs;};}
2024-09-22 23:16:10 -04:00
../common/nix-on-droid.nix
]
++ mods;
};
}