dotfiles/flake.nix

233 lines
6.1 KiB
Nix
Raw 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
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
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
2024-01-27 14:40:06 +02:00
attic.url = "github:zhaofengli/attic";
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,
deploy-rs,
flake-parts,
home-manager,
...
}: 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
homeConfigurations = let
mkHomeConfiguration = name: user: system: let
2024-01-28 16:51:55 +02:00
pkgs = self.lib.nixpkgs.mkPkgs {inherit system;};
in
inputs.home-manager.lib.homeManagerConfiguration {
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
'';
}
(./users + "/${name}")
];
};
2023-12-31 15:09:25 +02:00
in {
"tudor" = mkHomeConfiguration "tudor" "tudor" "x86_64-linux";
"tudor@pepper-penguin" = mkHomeConfiguration "tudor@pepper-penguin" "tudor" "x86_64-linux";
};
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;
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; [
nix
self'.packages.home-manager
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;
2024-01-28 18:46:42 +02:00
ansible-lint = {
enable = true;
};
};
settings.ansible-lint = {
subdir = "ansible";
2024-01-28 16:28:07 +02:00
};
};
};
};
};
2022-01-18 13:40:11 +02:00
}