nixos/flake.nix

116 lines
3.2 KiB
Nix
Raw Normal View History

2021-07-13 09:53:22 +01:00
{
inputs = {
2024-06-01 11:41:26 +01:00
nixpkgs.url = "github:NixOS/nixpkgs/release-24.05";
nixos-unstable.url = "github:NixOS/nixpkgs/master";
2024-04-24 16:05:05 +01:00
local-unstable.url = "path:///home/giulio/dev/nixpkgs";
2021-07-13 09:53:22 +01:00
home-manager = {
2024-06-01 11:41:26 +01:00
url = "github:nix-community/home-manager/release-24.05";
2021-07-13 09:53:22 +01:00
inputs.nixpkgs.follows = "nixpkgs";
2021-11-25 11:42:32 +00:00
};
nvidia-patch = {
url = "github:icewind1991/nvidia-patch-nixos";
inputs.nixpkgs.follows = "nixpkgs";
};
2021-07-13 09:53:22 +01:00
};
2021-10-13 13:29:07 +01:00
outputs = { self, nixpkgs, nixos-unstable, local-unstable, home-manager, nvidia-patch }:
2021-11-25 11:42:32 +00:00
let
sysLinuxX64 = "x86_64-linux";
sysDarwin = "aarch64-darwin";
sysLinuxAarch = "aarch64-linux";
2021-10-13 13:29:07 +01:00
wrapPkgsSystem = { system, cudaSupport ? false }:
let
config = {
inherit cudaSupport;
allowUnfree = true;
};
extOverlays = [
(nvidia-patch.overlays.default)
];
in
2022-10-13 18:05:31 +01:00
import nixpkgs rec {
inherit system config;
2023-02-15 20:38:50 +00:00
unstablePkgs = import nixos-unstable {
inherit system config;
overlays = extOverlays;
2024-02-21 11:43:26 +00:00
};
localPkgs = import local-unstable {
inherit system config;
overlays = extOverlays;
2024-02-21 11:43:26 +00:00
};
2022-10-13 18:05:31 +01:00
overlays = [
(final: prev: { inherit unstablePkgs; })
2024-02-21 11:43:26 +00:00
(final: prev: { inherit localPkgs; })
] ++ extOverlays;
2022-10-13 18:05:31 +01:00
};
2021-10-13 13:29:07 +01:00
wrapUtils = { pkgs, system }:
let
inherit (pkgs.lib) makeScope;
inherit (pkgs) newScope;
in
makeScope newScope (self: rec {
inherit nixpkgs home-manager nixos-unstable;
inherit (self.callPackage ./lib/utils.nix { }) mkSysRole mkHomeRole;
inherit (user) mkUser;
user = self.callPackage ./lib/user.nix { };
host = self.callPackage ./lib/host.nix { };
});
2023-02-11 01:32:17 +00:00
2024-03-13 18:38:32 +00:00
pkgsLinuxX64Cuda = wrapPkgsSystem { system = sysLinuxX64; };
utilsLinuxX64Cuda = wrapUtils { system = sysLinuxX64; pkgs = pkgsLinuxX64Cuda; };
pkgsLinuxAarch = wrapPkgsSystem { system = sysLinuxAarch; };
utilsLinuxAarch = wrapUtils { system = sysLinuxAarch; pkgs = pkgsLinuxAarch; };
2023-02-06 22:33:36 +00:00
pkgsDarwin = wrapPkgsSystem { system = sysDarwin; };
utilsDarwin = wrapUtils { system = sysDarwin; pkgs = pkgsDarwin; };
2022-11-22 12:05:53 +00:00
in
{
2021-11-25 11:42:32 +00:00
nixosConfigurations = {
architect = utilsLinuxX64Cuda.host.mkHost {
2021-11-25 11:42:32 +00:00
name = "architect";
2021-11-25 11:47:13 +00:00
users = [{
user = "giulio";
roles = [ ];
}];
2021-11-25 11:42:32 +00:00
};
};
2023-02-17 17:04:32 +00:00
2023-02-06 22:30:35 +00:00
homeConfigurations = {
giulioMac = utilsDarwin.user.mkHMUser {
name = "giulio";
roles = [ "ssh" ];
};
2023-02-06 22:33:36 +00:00
giulioAarch = utilsLinuxAarch.user.mkHMUser {
name = "giulio";
roles = [ "ssh" ];
};
giulioX64 = utilsLinuxX64Cuda.user.mkHMUser {
name = "giulio";
2023-03-03 18:03:26 +00:00
roles = [ "ssh" "go" ];
};
giulioX64NoSSH = utilsLinuxX64Cuda.user.mkHMUser {
2023-03-03 18:04:12 +00:00
name = "giulio";
roles = [ "go" ];
};
2022-10-14 13:17:50 +01:00
};
2023-02-17 17:04:32 +00:00
defaultTemplate = self.templates.basicShell;
templates = {
basicShell = {
path = ./templates/basicShell;
description = "A barebone shell with custom defined packages";
};
2023-02-17 17:04:32 +00:00
};
2021-08-23 12:25:36 +01:00
};
2021-07-13 09:53:22 +01:00
}