dotfiles/flake.nix

237 lines
6.7 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";
};
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
# nix-alien = {
# url = "github:thiagokokada/nix-alien";
# inputs.nixpkgs.follows = "nixpkgs";
# };
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
2023-01-14 21:37:45 +02:00
co-work.url = "git+ssh://git@github.com/tudurom/co-work.git";
2023-10-11 14:39:49 +03:00
site.url = "github:tudurom/site";
blog.url = "github:tudurom/blog";
2022-01-18 13:40:11 +02:00
};
2022-01-22 16:39:24 +02:00
outputs = inputs@{ self, haumea, nixpkgs, deploy-rs, unstable, flake-parts, home-manager, ... }:
2023-01-14 21:37:45 +02:00
let
vars = {
stateVersion = "23.11";
2023-01-14 21:37:45 +02:00
};
2023-12-31 15:09:25 +02:00
specialArgs = {
inherit vars;
flake = {
inherit self inputs;
};
2023-11-27 01:01:50 +02:00
};
in flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" ];
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 = [
{
nixpkgs = {
config = self.lib.nixpkgs.defaultConfig;
overlays = self.lib.nixpkgs.mkDefaultOverlays { inherit system; };
};
}
inputs.agenix.nixosModules.default
{
environment.systemPackages = [ inputs.agenix.packages.${system}.default ];
# enable ssh host key generation
services.openssh.enable = true;
}
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}
];
in nixpkgs.lib.nixosSystem {
inherit system modules specialArgs;
};
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
pkgs = self.lib.nixpkgs.mkPkgs { inherit system; };
in inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = specialArgs;
2023-12-31 15:09:25 +02:00
modules = (self.lib.hm-modules) ++ [
{
nixpkgs = {
config = self.lib.nixpkgs.defaultConfig;
overlays = self.lib.nixpkgs.mkDefaultOverlays { inherit system; };
};
}
{
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}")
];
};
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
mkDeployPkgs = system: import nixpkgs {
inherit system;
overlays = [
deploy-rs.overlay
(self: super: {
deploy-rs = {
inherit (nixpkgs.legacyPackages."${system}") deploy-rs;
lib = super.deploy-rs.lib;
};
})
];
};
configuration = self.nixosConfigurations."ceres";
in {
hostname = "ceres.lamb-monitor.ts.net";
profiles.system = {
2023-12-27 11:06:51 +02:00
user = "root";
2023-12-31 15:09:25 +02:00
path = (mkDeployPkgs configuration.pkgs.system).deploy-rs.lib.activate.nixos configuration;
};
2023-11-27 01:01:50 +02:00
};
};
2022-01-22 18:39:56 +02:00
2023-12-28 15:23:08 +02:00
perSystem = {config, pkgs, system, self', ... }: let
deployPkgs = import nixpkgs {
inherit system;
overlays = [
deploy-rs.overlay
(final: prev: {
deploy-rs = { inherit (pkgs) deploy-rs; lib = prev.deploy-rs.lib; };
})
];
};
in {
apps.deploy-rs = {
type = "app";
program = "${deployPkgs.deploy-rs.deploy-rs}/bin/deploy";
};
2023-10-11 14:39:49 +03:00
packages.default = pkgs.nix;
packages.home-manager = pkgs.home-manager;
packages.nixos-rebuild = pkgs.nixos-rebuild;
2023-12-28 15:23:08 +02:00
packages.agenix = inputs.agenix.packages.${system}.default;
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
nix
self'.packages.home-manager
self'.packages.nixos-rebuild
2023-12-28 15:23:08 +02:00
self'.packages.agenix
deployPkgs.deploy-rs.deploy-rs
nil
];
};
2023-10-11 14:39:49 +03:00
checks = (deployPkgs.deploy-rs.lib.deployChecks self.deploy) // {
ansible-lint = pkgs.stdenvNoCC.mkDerivation {
name = "run-ansible-lint";
src = ./.;
dontBuild = true;
doCheck = true;
buildInputs = with pkgs; [ ansible-lint git ];
checkPhase = ''
cd ./ansible
env "HOME=$TMPDIR" ansible-lint --offline
'';
installPhase = ''
mkdir "$out"
'';
};
};
};
};
2022-01-18 13:40:11 +02:00
}