dotfiles/flake.nix

149 lines
4.8 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 = {
2023-06-02 23:28:04 +03:00
url = "github:rycee/home-manager/release-23.05";
2023-01-14 21:37:45 +02:00
inputs.nixpkgs.follows = "nixpkgs";
};
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-01-14 21:37:45 +02:00
co-work.url = "git+ssh://git@github.com/tudurom/co-work.git";
2022-01-22 18:39:56 +02: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, ... } @ 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; };
})
];
};
2023-01-14 21:37:45 +02:00
mkPkgs = system: import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [
2023-06-04 15:24:01 +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-01-14 21:37:45 +02:00
mkNixOSModules = name: system: [
{
nixpkgs.pkgs = mkPkgs system;
_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-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-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;
};
mkNonNixOSEnvironment = name: user: system: inputs.home-manager.lib.homeManagerConfiguration rec {
2023-01-14 21:37:45 +02:00
pkgs = mkPkgs system;
2023-06-02 23:28:04 +03:00
extraSpecialArgs = {inherit inputs vars; configName = "normal-linux"; };
2023-01-14 21:37:45 +02:00
modules = [
{
_module.args.nixpkgs = nixpkgs;
_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";
};
packages = [
pkgs.home-manager
];
2023-01-14 21:37:45 +02:00
};
programs.bash.profileExtra = ''
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
'';
2023-01-14 21:37:45 +02:00
}
(./users + "/${name}" + /home.nix)
2022-01-18 13:40:11 +02:00
];
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";
packages.x86_64-linux."tudor" = self.homeConfigurations."tudor".activationPackage;
2022-01-22 18:39:56 +02:00
packages.x86_64-linux.default = (mkPkgs "x86_64-linux").nix;
apps.x86_64-linux.deploy-rs = deploy-rs.apps.x86_64-linux.deploy-rs;
deploy.nodes."ceres" = let deployPkgs = mkDeployPkgs "x86_64-linux"; in {
hostname = "ceres.lamb-monitor.ts.net";
profiles.system = {
sshUser = "root";
path = deployPkgs.deploy-rs.lib.activate.nixos self.nixosConfigurations."ceres";
};
};
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
2022-01-18 13:40:11 +02:00
};
}