dotfiles/flake.nix

252 lines
6.8 KiB
Nix
Raw Permalink Normal View History

2022-01-18 13:40:11 +02:00
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
2023-01-28 23:03:00 +02:00
unstable.url = "github:nixos/nixpkgs/nixos-unstable";
2023-11-27 01:01:50 +02:00
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
2023-12-31 15:09:25 +02:00
haumea = {
url = "github:nix-community/haumea/v0.2.2";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-01-28 16:28:07 +02:00
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-11-27 01:01:50 +02:00
2023-06-04 14:08:22 +03:00
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
inputs.darwin.follows = "";
};
2023-11-27 01:01:50 +02:00
2022-01-18 13:40:11 +02:00
home-manager = {
url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixpkgs";
2023-01-14 21:37:45 +02:00
};
2023-11-27 01:01:50 +02:00
home-manager-unstable = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "unstable";
};
2023-01-14 21:37:45 +02:00
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
2023-11-27 01:01:50 +02:00
2023-01-14 21:37:45 +02:00
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
2023-11-27 01:01:50 +02:00
2024-04-01 14:55:17 +03:00
niri = {
url = "github:sodiboo/niri-flake";
inputs.nixpkgs.follows = "unstable";
};
2023-01-14 21:37:45 +02:00
nixos-wsl = {
url = "github:nix-community/NixOS-WSL";
2022-01-18 13:40:11 +02:00
inputs.nixpkgs.follows = "nixpkgs";
};
2023-11-27 01:01:50 +02:00
2023-06-17 23:32:52 +03:00
nixgl = {
url = "github:guibou/nixGL";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-11-27 01:01:50 +02:00
2023-08-06 22:26:32 +03:00
hypr-contrib = {
url = "github:hyprwm/contrib";
2024-01-13 12:31:10 +02:00
inputs.nixpkgs.follows = "nixpkgs";
2023-08-06 22:26:32 +03:00
};
2023-11-27 01:01:50 +02:00
2023-09-16 12:30:30 +03:00
yarr-nix = {
url = "git+https://git.tudorr.ro/tudor/yarr-nix.git";
inputs.nixpkgs.follows = "nixpkgs";
};
2022-01-18 13:40:11 +02:00
};
2022-01-22 16:39:24 +02:00
2024-01-28 16:51:55 +02:00
outputs = inputs @ {
self,
haumea,
pre-commit-hooks,
nixpkgs,
unstable,
2024-01-28 16:51:55 +02:00
deploy-rs,
flake-parts,
home-manager,
home-manager-unstable,
2024-01-28 16:51:55 +02:00
...
}: let
systems = ["x86_64-linux" "aarch64-linux"];
vars = {
stateVersion = "23.11";
};
2024-01-28 16:51:55 +02:00
specialArgs = {
inherit vars;
flake = {
inherit self inputs;
2023-11-27 01:01:50 +02:00
};
2024-01-28 16:51:55 +02:00
};
2024-01-13 13:44:13 +02:00
2024-01-28 16:51:55 +02:00
deployPkgs = with nixpkgs.lib; listToAttrs (map (system: nameValuePair system (self.lib.deploy.mkPkgs system)) systems);
in
flake-parts.lib.mkFlake {inherit inputs;} {
inherit systems;
2024-01-13 13:44:13 +02:00
flake = {
2023-12-31 15:09:25 +02:00
lib = haumea.lib.load {
src = ./lib;
inputs = {
inherit nixpkgs inputs;
};
};
nixosConfigurations = let
mkNixOSSystem = name: system: let
modules = [
inputs.agenix.nixosModules.default
{
2024-01-28 16:51:55 +02:00
environment.systemPackages = [inputs.agenix.packages.${system}.default];
2023-12-31 15:09:25 +02:00
# enable ssh host key generation
services.openssh.enable = true;
}
2024-01-17 19:51:09 +02:00
2023-12-31 15:09:25 +02:00
inputs.home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = false;
extraSpecialArgs = specialArgs;
2023-12-31 15:09:25 +02:00
sharedModules = self.lib.hm-modules;
};
}
./hosts/${name}
];
2024-01-28 16:51:55 +02:00
in
nixpkgs.lib.nixosSystem {
pkgs = self.lib.nixpkgs.mkPkgs {inherit system;};
inherit system modules specialArgs;
};
2023-12-31 15:09:25 +02:00
in {
"ceres" = mkNixOSSystem "ceres" "x86_64-linux";
"wsl2" = mkNixOSSystem "wsl2" "x86_64-linux";
2023-12-31 15:09:25 +02:00
};
2023-12-31 15:09:25 +02:00
homeConfigurations = let
mkHomeConfiguration = name: user: system: let
stablePkgs = self.lib.nixpkgs.mkPkgs {inherit system;};
hm = inputs.home-manager;
in
mkHomeConfiguration' hm stablePkgs name user;
mkHomeConfigurationUnstable = name: user: system: let
unstablePkgs = self.lib.nixpkgs.mkPkgs {
inherit system;
nixpkgsVersion = unstable;
};
hm = inputs.home-manager-unstable;
2024-01-28 16:51:55 +02:00
in
mkHomeConfiguration' hm unstablePkgs name user;
mkHomeConfiguration' = hm: pkgs: name: user:
hm.lib.homeManagerConfiguration {
2024-01-28 16:51:55 +02:00
inherit pkgs;
extraSpecialArgs = specialArgs;
modules =
self.lib.hm-modules
++ [
{
home = {
homeDirectory = "/home/${user}";
username = user;
sessionVariables = {
GIT_SSH = "/usr/bin/ssh";
};
};
programs.bash.profileExtra = ''
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
'';
2024-03-16 13:45:04 +02:00
nix.package = pkgs.nix;
2024-01-28 16:51:55 +02:00
}
(./users + "/${name}")
];
};
2023-12-31 15:09:25 +02:00
in {
"tudor" = mkHomeConfiguration "tudor" "tudor" "x86_64-linux";
"tudor@pepper-penguin" = mkHomeConfigurationUnstable "tudor@pepper-penguin" "tudor" "x86_64-linux";
2023-12-31 15:09:25 +02:00
};
2023-12-31 15:09:25 +02:00
deploy.nodes."ceres" = let
2024-01-13 13:44:13 +02:00
cfg = self.nixosConfigurations."ceres";
2023-12-31 15:09:25 +02:00
in {
hostname = "ceres.lamb-monitor.ts.net";
profiles.system = {
2023-12-27 11:06:51 +02:00
user = "root";
2024-01-13 13:44:13 +02:00
path = deployPkgs.${cfg.pkgs.system}.deploy-rs.lib.activate.nixos cfg;
};
2023-11-27 01:01:50 +02:00
};
2022-01-22 18:39:56 +02:00
2024-01-13 13:44:13 +02:00
checks."x86_64-linux" = deployPkgs."x86_64-linux".deploy-rs.lib.deployChecks self.deploy;
};
2023-10-11 14:39:49 +03:00
2024-01-28 16:51:55 +02:00
perSystem = {
pkgs,
system,
self',
...
}: {
packages.default = pkgs.nix;
packages.nixos-rebuild = pkgs.nixos-rebuild;
2024-01-13 13:44:13 +02:00
packages.home-manager = inputs.home-manager.packages.${system}.default;
packages.home-manager-unstable = inputs.home-manager-unstable.packages.${system}.default;
2023-12-28 15:23:08 +02:00
packages.agenix = inputs.agenix.packages.${system}.default;
2024-01-13 13:44:13 +02:00
packages.deploy-rs = deployPkgs.${system}.deploy-rs.deploy-rs;
devShells.default = pkgs.mkShell {
2024-01-28 16:55:20 +02:00
shellHook =
self'.checks.pre-commit-check.shellHook
+ ''
/usr/bin/env git config blame.ignoreRevsFile .git-blame-ignore-revs
'';
buildInputs = with pkgs; [
self'.packages.home-manager
self'.packages.home-manager-unstable
self'.packages.nixos-rebuild
2023-12-28 15:23:08 +02:00
self'.packages.agenix
2024-01-13 13:44:13 +02:00
self'.packages.deploy-rs
nil
2024-01-28 16:28:07 +02:00
alejandra
statix
deadnix
];
};
2023-10-11 14:39:49 +03:00
2024-01-13 13:44:13 +02:00
checks = {
2024-01-28 16:28:07 +02:00
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
statix.enable = true;
deadnix.enable = true;
};
};
};
};
};
2022-01-18 13:40:11 +02:00
}