nixos-config/flake.nix

210 lines
6.9 KiB
Nix
Raw Normal View History

2020-09-23 10:36:46 +02:00
{
2023-07-22 18:49:30 +02:00
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
2020-09-23 10:36:46 +02:00
2023-07-22 18:49:30 +02:00
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
2023-07-22 18:49:30 +02:00
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
2021-05-28 00:19:47 +02:00
2023-07-22 18:49:30 +02:00
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
2020-09-24 12:35:45 +02:00
2023-07-22 18:49:30 +02:00
flake-utils.url = "github:numtide/flake-utils";
2020-09-23 10:36:46 +02:00
2023-07-22 18:49:30 +02:00
home-manager = {
url = "github:nix-community/home-manager/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
};
2020-09-23 10:36:46 +02:00
2023-07-22 18:49:30 +02:00
nur.url = "github:nix-community/NUR/master";
2022-05-04 03:02:47 +02:00
2023-07-22 18:49:30 +02:00
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
2022-05-05 21:24:46 +02:00
2023-07-22 18:49:30 +02:00
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
};
2020-09-24 12:35:45 +02:00
2023-07-22 18:49:30 +02:00
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-stable.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
nvim-kitty-navigator = {
url = "github:hermitmaster/nvim-kitty-navigator";
flake = false;
};
};
2023-07-22 18:49:30 +02:00
outputs = { self, nixpkgs, nixpkgs-unstable, nixos-hardware, flake-parts
, flake-utils, home-manager, nur, agenix, deploy-rs, pre-commit-hooks
, nvim-kitty-navigator }@inputs:
2023-07-22 18:49:30 +02:00
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" ];
imports = [ ];
flake = rec {
lib = rec {
createSystem = hostName:
{ hardwareConfig, config }:
({ pkgs, lib, ... }: {
networking.hostName = hostName;
nixpkgs.overlays = [ nur.overlay self.overlays.default ];
2023-07-22 18:49:30 +02:00
imports = [
nixosModules.flakeDefaults
agenix.nixosModules.default
hardwareConfig
config
];
2023-07-22 18:49:30 +02:00
environment.systemPackages =
[ agenix.packages.x86_64-linux.default ];
});
createUser' = import ./lib/createUser.nix;
createUser = name: args:
({ pkgs, ... }@args2:
(createUser' name args) ({ inherit home-manager; } // args2));
createMediaGroup = _: { users.groups.media.gid = 600; };
};
2020-09-23 10:36:46 +02:00
overlays.default = final: prev: {
unstable = import nixpkgs-unstable {
inherit (prev) system;
config.allowUnfree = true;
};
inherit (self.packages.${prev.system}) deconz;
vimPlugins = prev.vimPlugins
// final.callPackage ./pkgs/vim-plugins { inherit inputs; };
};
2023-07-22 18:49:30 +02:00
nixosModules = {
flakeDefaults = import ./modules/flakeDefaults.nix;
systemdNotify = import ./modules/systemdNotify.nix;
};
2020-09-27 14:27:25 +02:00
2023-07-22 18:49:30 +02:00
homeManagerModules = {
git = import ./home/modules/git.nix;
firefox = import ./home/modules/firefox/firefox.nix;
tor-browser = import ./home/modules/firefox/tor-browser.nix;
2022-05-05 21:24:46 +02:00
};
2023-07-22 18:49:30 +02:00
nixosConfigurations = {
home-pc = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
nixpkgs.nixosModules.notDetected
nixos-hardware.nixosModules.common-pc
nixos-hardware.nixosModules.common-pc-ssd
nixos-hardware.nixosModules.common-cpu-amd-pstate
nixos-hardware.nixosModules.common-gpu-amd
(lib.createSystem "home-pc" {
hardwareConfig = ./hardware/home-pc.nix;
config = ./home-pc.nix;
})
lib.createMediaGroup
(lib.createUser "felschr" {
user.extraGroups = [ "wheel" "audio" "disk" "media" ];
modules = [ homeManagerModules.git ];
config = ./home/felschr.nix;
})
({ pkgs, ... }: {
environment.systemPackages =
[ deploy-rs.defaultPackage.x86_64-linux ];
})
];
specialArgs = { inherit inputs; };
};
pilot1 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
nixpkgs.nixosModules.notDetected
nixos-hardware.nixosModules.common-pc
nixos-hardware.nixosModules.common-pc-ssd
nixos-hardware.nixosModules.common-cpu-intel
(lib.createSystem "pilot1" {
hardwareConfig = ./hardware/pilot1.nix;
config = ./work-pc.nix;
})
(lib.createUser "felschr" {
user.extraGroups = [ "wheel" "audio" "disk" ];
modules = [ homeManagerModules.git ];
config = ./home/felschr-work.nix;
})
];
specialArgs = { inherit inputs; };
};
home-server = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
nixpkgs.nixosModules.notDetected
nixos-hardware.nixosModules.common-pc
nixos-hardware.nixosModules.common-pc-ssd
nixos-hardware.nixosModules.common-cpu-intel-kaby-lake
(lib.createSystem "home-server" {
hardwareConfig = ./hardware/lattepanda.nix;
config = ./home-server.nix;
})
lib.createMediaGroup
(lib.createUser "felschr" {
user = {
extraGroups = [ "wheel" "audio" "disk" "media" ];
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP751vlJUnB7Pfe1KNr6weWkx/rkP4J3lTYpAekHdOgV"
];
};
modules = [ homeManagerModules.git ];
config = ./home/felschr-server.nix;
})
];
specialArgs = { inherit inputs; };
};
2022-08-08 22:52:32 +02:00
};
2023-07-22 18:49:30 +02:00
deploy.nodes.home-server = {
hostname = "192.168.1.102";
profiles.system = {
user = "felschr";
path = deploy-rs.lib.x86_64-linux.activate.nixos
self.nixosConfigurations.home-server;
};
};
};
perSystem = { system, config, pkgs, ... }: {
_module.args.pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
2023-07-27 18:26:39 +02:00
packages = import ./pkgs { inherit pkgs; };
apps = {
deconz = flake-utils.lib.mkApp { drv = config.packages.deconz; };
};
devShells.default =
pkgs.mkShell { inherit (config.checks.pre-commit) shellHook; };
2022-08-08 23:53:33 +02:00
checks = deploy-rs.lib.${system}.deployChecks self.deploy // {
pre-commit = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixfmt.enable = true;
shellcheck.enable = true;
};
};
};
2023-07-22 18:49:30 +02:00
formatter = pkgs.nixfmt;
};
};
2020-09-23 10:36:46 +02:00
}