dotfiles/flake.nix

239 lines
7.1 KiB
Nix
Raw Normal View History

2022-01-18 13:40:11 +02:00
{
inputs = {
2023-06-02 23:28:04 +03:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
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";
};
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.05";
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";
};
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
2023-12-17 17:04:09 +02:00
outputs = inputs@{ self, nixpkgs, deploy-rs, unstable, flake-parts, ... }:
2023-01-14 21:37:45 +02:00
let
vars = {
stateVersion = "23.05";
2023-06-04 14:09:14 +03:00
username = "tudor";
2023-01-14 21:37:45 +02:00
};
mkPkgs = pkgs: system: import pkgs {
2023-01-14 21:37:45 +02:00
inherit system;
config.allowUnfree = true;
overlays = [
2023-08-06 22:26:32 +03:00
inputs.hypr-contrib.overlays.default
2023-08-08 18:27:20 +03:00
inputs.nixgl.overlays.default
inputs.agenix.overlays.default
2023-09-16 12:30:30 +03:00
inputs.yarr-nix.overlays.default
2023-10-11 14:39:49 +03:00
(final: prev: {
2023-01-14 21:37:45 +02:00
tudor.site = inputs.site.packages.${system}.site;
tudor.blog = inputs.blog.packages.${system}.blog;
2023-01-14 22:19:13 +02:00
tudor.pong = inputs.co-work.packages.${system}.pong;
2023-01-28 23:03:00 +02:00
unstable = import inputs.unstable { inherit system; config.allowUnfree = true; };
home-manager = inputs.home-manager.packages.${system}.home-manager;
2022-01-18 13:40:11 +02:00
})
];
};
2023-06-02 23:28:04 +03:00
2023-06-17 23:32:52 +03:00
mkHmDependencies = system: [
inputs.agenix.homeManagerModules.default
2023-06-17 23:32:52 +03:00
];
2023-01-14 21:37:45 +02:00
mkNixOSModules = name: system: [
{
nixpkgs.pkgs = mkPkgs nixpkgs system;
2023-01-14 21:37:45 +02:00
_module.args.nixpkgs = nixpkgs;
_module.args.self = self;
2023-06-02 23:49:43 +03:00
_module.args.inputs = inputs;
2023-01-14 21:37:45 +02:00
_module.args.configName = name;
2023-06-02 23:49:43 +03:00
_module.args.vars = vars;
2023-01-14 21:37:45 +02:00
}
2023-06-04 14:08:22 +03:00
inputs.agenix.nixosModules.default
{
environment.systemPackages = [ inputs.agenix.packages.${system}.default ];
# enable ssh host key generation
services.openssh.enable = true;
}
2023-01-14 21:37:45 +02:00
inputs.home-manager.nixosModules.home-manager
2023-06-02 23:49:43 +03:00
inputs.nixos-wsl.nixosModules.wsl
2023-09-16 12:30:30 +03:00
inputs.yarr-nix.nixosModules.default
2023-01-14 21:37:45 +02:00
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = false;
2023-06-02 23:28:04 +03:00
extraSpecialArgs = { inherit inputs vars; configName = name; };
2023-08-08 19:33:10 +03:00
sharedModules = mkHmDependencies system;
2023-01-14 21:37:45 +02:00
};
}
./hosts/${name}
2022-01-18 13:40:11 +02:00
];
2023-01-14 21:37:45 +02:00
mkNixOSSystem = name: system: nixpkgs.lib.nixosSystem {
inherit system;
modules = mkNixOSModules name system;
};
2023-10-11 14:39:49 +03:00
mkNonNixOSEnvironment = name: user: system: inputs.home-manager.lib.homeManagerConfiguration {
pkgs = mkPkgs nixpkgs system;
2023-06-02 23:28:04 +03:00
extraSpecialArgs = {inherit inputs vars; configName = "normal-linux"; };
2023-06-17 23:32:52 +03:00
modules = (mkHmDependencies system) ++ [
2023-01-14 21:37:45 +02:00
{
_module.args.nixpkgs = nixpkgs;
2023-01-14 21:37:45 +02:00
_module.args.inputs = inputs;
2023-06-02 23:49:43 +03:00
_module.args.vars = vars;
2023-01-14 21:37:45 +02:00
}
{
home = {
homeDirectory = "/home/${user}";
username = user;
sessionVariables = {
GIT_SSH = "/usr/bin/ssh";
};
2023-01-14 21:37:45 +02:00
};
programs.bash.profileExtra = ''
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
'';
2023-01-14 21:37:45 +02:00
}
2023-06-17 22:54:44 +03:00
(./users + "/${name}")
2022-01-18 13:40:11 +02:00
];
2023-01-14 21:37:45 +02:00
};
2023-11-27 01:01:50 +02:00
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;
};
})
];
};
in flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" ];
flake = {
nixosConfigurations."ceres" = mkNixOSSystem "ceres" "x86_64-linux";
nixosConfigurations."wsl2" = mkNixOSSystem "wsl2" "x86_64-linux";
packages."x86_64-linux"."tudor" = self.homeConfigurations."tudor".activationPackage;
packages."x86_64-linux"."tudor@pepper-penguin" = self.homeConfigurations."tudor@pepper-penguin".activationPackage;
homeConfigurations."tudor" = mkNonNixOSEnvironment "tudor" "tudor" "x86_64-linux";
homeConfigurations."tudor@pepper-penguin" = mkNonNixOSEnvironment "tudor@pepper-penguin" "tudor" "x86_64-linux";
deploy.nodes."ceres" = {
hostname = "ceres.lamb-monitor.ts.net";
profiles.system = {
sshUser = "root";
path = (mkDeployPkgs "x86_64-linux").deploy-rs.lib.activate.nixos self.nixosConfigurations."ceres";
};
2023-11-27 01:01:50 +02:00
};
};
2022-01-22 18:39:56 +02:00
perSystem = {config, pkgs, system, ... }: let
deployPkgs = import nixpkgs {
inherit system;
overlays = [
deploy-rs.overlay
(final: prev: {
deploy-rs = { inherit (pkgs) deploy-rs; lib = prev.deploy-rs.lib; };
})
];
};
in {
_module.args.pkgs = mkPkgs nixpkgs system;
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;
packages.agenix = pkgs.agenix;
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
nix
home-manager
nixos-rebuild
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
}