2024-08-07 14:47:32 -04:00
|
|
|
inputs: rec {
|
|
|
|
# Import pkgs from a nixpkgs instance
|
2024-09-04 23:41:56 -04:00
|
|
|
mkPkgs = {
|
|
|
|
system,
|
|
|
|
nixpkgs,
|
2024-11-30 23:41:00 -05:00
|
|
|
cfg ? {},
|
2024-09-04 23:41:56 -04:00
|
|
|
cudaSupport ? false,
|
|
|
|
}:
|
2024-08-07 14:47:32 -04:00
|
|
|
import nixpkgs {
|
2024-05-20 22:41:45 -04:00
|
|
|
inherit system;
|
2024-11-30 23:41:00 -05:00
|
|
|
overlays = [inputs.self.overlays.build-failures] ++ (cfg.overlays or []);
|
|
|
|
config =
|
|
|
|
{
|
|
|
|
inherit cudaSupport;
|
|
|
|
allowUnfree = true;
|
|
|
|
}
|
|
|
|
// (cfg.config or {});
|
2024-05-20 22:41:45 -04:00
|
|
|
};
|
|
|
|
|
2024-09-25 15:34:56 -04:00
|
|
|
# Enable use of `nixpkgs.overlays` on both NixOS and NixOnDroid
|
2024-09-22 23:16:10 -04:00
|
|
|
allowModularOverrides = {
|
2024-09-23 01:58:59 -04:00
|
|
|
cudaSupport ? false,
|
2024-09-04 23:41:56 -04:00
|
|
|
system,
|
2024-09-22 23:16:10 -04:00
|
|
|
}: ({config, ...}: let
|
|
|
|
pkgs = mkPkgs {
|
2024-11-30 23:41:00 -05:00
|
|
|
cfg = config.nixpkgs;
|
2024-09-22 23:16:10 -04:00
|
|
|
inherit system cudaSupport;
|
|
|
|
inherit (inputs) nixpkgs;
|
2024-05-20 22:41:45 -04:00
|
|
|
};
|
2024-11-30 23:41:00 -05:00
|
|
|
inherit (pkgs.lib) mkForce;
|
2024-09-22 23:16:10 -04:00
|
|
|
in {
|
2024-11-30 23:41:00 -05:00
|
|
|
_module.args.pkgs = mkForce pkgs;
|
2024-09-22 23:16:10 -04:00
|
|
|
});
|
2024-05-20 22:41:45 -04:00
|
|
|
|
|
|
|
# Default system
|
2024-09-04 23:41:56 -04:00
|
|
|
mkNixOS = {
|
|
|
|
extraModules ? [],
|
|
|
|
cudaSupport ? false,
|
2024-11-22 23:15:13 -05:00
|
|
|
mainUser ? "matt",
|
2024-09-04 23:41:56 -04:00
|
|
|
}:
|
2024-06-24 11:38:30 -04:00
|
|
|
inputs.nixpkgs.lib.nixosSystem rec {
|
2024-05-20 22:41:45 -04:00
|
|
|
system = "x86_64-linux";
|
2024-11-22 23:15:13 -05:00
|
|
|
specialArgs = inputs // {inherit mainUser;};
|
2024-05-20 22:41:45 -04:00
|
|
|
modules =
|
|
|
|
[
|
2024-09-22 23:16:10 -04:00
|
|
|
(allowModularOverrides {inherit system cudaSupport;})
|
2024-11-22 23:15:13 -05:00
|
|
|
inputs.home-manager.nixosModules.home-manager
|
2024-05-20 22:41:45 -04:00
|
|
|
{home-manager.extraSpecialArgs = specialArgs;}
|
|
|
|
]
|
2024-09-04 23:41:56 -04:00
|
|
|
++ extraModules;
|
2024-05-20 22:41:45 -04:00
|
|
|
};
|
|
|
|
|
2024-11-20 16:13:12 -05:00
|
|
|
mkNixOnDroid = extraModules: let
|
2024-09-23 01:58:59 -04:00
|
|
|
system = "aarch64-linux";
|
|
|
|
in
|
2024-06-24 11:38:30 -04:00
|
|
|
inputs.nix-on-droid.lib.nixOnDroidConfiguration rec {
|
2024-09-22 23:16:10 -04:00
|
|
|
extraSpecialArgs = inputs;
|
2024-06-24 11:38:30 -04:00
|
|
|
home-manager-path = inputs.home-manager.outPath;
|
2024-09-23 01:58:59 -04:00
|
|
|
pkgs = mkPkgs {
|
|
|
|
inherit system;
|
|
|
|
inherit (inputs) nixpkgs;
|
|
|
|
};
|
2024-05-20 22:41:45 -04:00
|
|
|
|
2024-09-22 23:16:10 -04:00
|
|
|
modules =
|
2024-05-20 22:41:45 -04:00
|
|
|
[
|
2024-09-23 01:58:59 -04:00
|
|
|
(allowModularOverrides {inherit system;})
|
2024-09-22 23:16:10 -04:00
|
|
|
|
|
|
|
({
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
2024-09-23 01:58:59 -04:00
|
|
|
inherit (lib) mkForce mkOption types;
|
2024-09-22 23:16:10 -04:00
|
|
|
in {
|
|
|
|
# Adapt NixOnDroid to NixOS options
|
2024-09-23 01:58:59 -04:00
|
|
|
options.environment = {
|
|
|
|
variables.FLAKE = mkOption {
|
2024-05-20 22:41:45 -04:00
|
|
|
type = with types; nullOr str;
|
|
|
|
};
|
2024-09-22 23:16:10 -04:00
|
|
|
systemPackages = mkOption {
|
2024-08-20 20:06:20 -04:00
|
|
|
type = with types; listOf package;
|
|
|
|
default = [];
|
|
|
|
};
|
2024-05-20 22:41:45 -04:00
|
|
|
};
|
2024-09-22 23:16:10 -04:00
|
|
|
|
2024-08-20 20:06:20 -04:00
|
|
|
config.environment.packages = config.environment.systemPackages;
|
2024-09-25 15:34:56 -04:00
|
|
|
|
2024-09-23 01:58:59 -04:00
|
|
|
# This disables the assertion that fails because of nixpkgs.overlays
|
|
|
|
config._module.args.isFlake = mkForce false;
|
2024-08-20 20:06:20 -04:00
|
|
|
})
|
2024-09-22 23:16:10 -04:00
|
|
|
|
2024-05-20 22:41:45 -04:00
|
|
|
{home-manager = {inherit extraSpecialArgs;};}
|
|
|
|
]
|
2024-11-20 16:13:12 -05:00
|
|
|
++ extraModules;
|
2024-05-20 22:41:45 -04:00
|
|
|
};
|
|
|
|
}
|