dotfiles/flake.nix

211 lines
6.6 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";
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs.nixpkgs.follows = "nixpkgs";
};
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 = "";
};
2022-01-18 13:40:11 +02:00
home-manager = {
url = "github:rycee/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
2023-01-14 21:37:45 +02:00
};
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
# nix-alien = {
# url = "github:thiagokokada/nix-alien";
# inputs.nixpkgs.follows = "nixpkgs";
# };
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
nixos-wsl = {
url = "github:nix-community/NixOS-WSL";
2022-01-18 13:40:11 +02:00
inputs.nixpkgs.follows = "nixpkgs";
};
2023-06-17 23:32:52 +03:00
nixgl = {
url = "github:guibou/nixGL";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-08-06 22:26:32 +03:00
hypr-contrib = {
url = "github:hyprwm/contrib";
};
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 = { self, nixpkgs, deploy-rs, unstable, ... } @ inputs:
2023-01-14 21:37:45 +02:00
let
vars = {
stateVersion = "22.05";
2023-06-04 14:09:14 +03:00
username = "tudor";
2023-01-14 21:37:45 +02:00
};
mkDeployPkgs = system: let
pkgs = import nixpkgs { inherit system; };
in import nixpkgs {
inherit system;
overlays = [
deploy-rs.overlay
(final: prev: {
deploy-rs = { inherit (pkgs) deploy-rs; lib = prev.deploy-rs.lib; };
})
];
};
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
};
x64Pkgs = mkPkgs nixpkgs "x86_64-linux";
x64DeployPkgs = mkDeployPkgs "x86_64-linux";
2023-01-14 21:37:45 +02:00
in
{
nixosConfigurations."ceres" = mkNixOSSystem "ceres" "x86_64-linux";
nixosConfigurations."wsl2" = mkNixOSSystem "wsl2" "x86_64-linux";
2022-01-22 18:39:56 +02:00
2023-01-14 21:37:45 +02:00
homeConfigurations."tudor" = mkNonNixOSEnvironment "tudor" "tudor" "x86_64-linux";
2023-06-17 22:55:35 +03:00
homeConfigurations."tudor@pepper-penguin" = mkNonNixOSEnvironment "tudor@pepper-penguin" "tudor" "x86_64-linux";
2023-01-14 21:37:45 +02:00
packages.x86_64-linux."tudor" = self.homeConfigurations."tudor".activationPackage;
2023-06-17 22:55:35 +03:00
packages.x86_64-linux."tudor@pepper-penguin" = self.homeConfigurations."tudor@pepper-penguin".activationPackage;
2022-01-22 18:39:56 +02:00
2023-08-27 01:13:02 +03:00
apps.x86_64-linux.deploy-rs = {
type = "app";
program = "${x64DeployPkgs.deploy-rs.deploy-rs}/bin/deploy";
};
2023-06-17 22:55:35 +03:00
packages.x86_64-linux.default = x64Pkgs.nix;
packages.x86_64-linux.home-manager = x64Pkgs.home-manager;
packages.x86_64-linux.nixos-rebuild = x64Pkgs.nixos-rebuild;
packages.x86_64-linux.agenix = x64Pkgs.agenix;
2023-10-11 14:39:49 +03:00
devShells.x86_64-linux.default = x64Pkgs.mkShell {
buildInputs = with x64Pkgs; [
nix
home-manager
nixos-rebuild
agenix
x64DeployPkgs.deploy-rs.deploy-rs
nil
];
};
deploy.nodes."ceres" = {
hostname = "ceres.lamb-monitor.ts.net";
profiles.system = {
sshUser = "root";
path = x64DeployPkgs.deploy-rs.lib.activate.nixos self.nixosConfigurations."ceres";
};
};
checks = (builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib) // {
x86_64-linux.ansible-lint = x64Pkgs.stdenvNoCC.mkDerivation {
name = "run-ansible-lint";
src = ./.;
dontBuild = true;
doCheck = true;
buildInputs = with x64Pkgs; [ ansible-lint git ];
checkPhase = ''
cd ./ansible
env HOME=$TMPDIR ansible-lint --offline
'';
installPhase = ''
mkdir "$out"
'';
};
};
2022-01-18 13:40:11 +02:00
};
}