dotfiles/system/flake.nix

75 lines
2.3 KiB
Nix
Raw Normal View History

2023-01-24 02:24:40 +07:00
{
description = "NixOS configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
2023-01-24 02:24:40 +07:00
utils.url = "github:gytis-ivaskevicius/flake-utils-plus";
nixos-hardware.url = "github:NixOS/nixos-hardware";
impermanence.url = "github:nix-community/impermanence";
# simply make rust-overlay available for the whole system
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-gaming = {
url = "github:fufexan/nix-gaming";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-05-11 05:33:08 +07:00
nixos-mailserver = {
url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-22_11.follows = "nixpkgs";
};
2023-01-24 02:24:40 +07:00
};
2023-05-11 05:33:08 +07:00
outputs = inputs@{ self, nixpkgs, utils, nixos-hardware, impermanence, nix-gaming, nixos-mailserver, ... }:
2023-01-24 02:24:40 +07:00
let
# IRL-related stuff I'd rather not put into git
2023-05-11 17:28:47 +07:00
priv =
if builtins.pathExists ./private.nix then (import ./private.nix)
else if builtins.pathExists ./private/default.nix then (import ./private)
else { };
2023-05-11 05:33:08 +07:00
getPriv = hostname: with builtins; if hasAttr hostname priv then getAttr hostname priv else { };
2023-05-11 17:28:47 +07:00
common = hostname: [ (getPriv hostname) ];
lib = nixpkgs.lib // {
2023-05-17 06:29:03 +07:00
quoteListenAddr = addr:
2023-05-11 17:28:47 +07:00
if nixpkgs.lib.hasInfix ":" addr then "[${addr}]" else addr;
};
mkHost = args @ { system ? "x86_64-linux", modules, ... }: {
2023-05-17 07:16:03 +07:00
inherit system;
extraArgs = {
inherit nixpkgs;
};
specialArgs = {
inherit lib;
hardware = nixos-hardware.nixosModules;
};
2023-05-11 17:28:47 +07:00
} // args;
2023-01-24 02:24:40 +07:00
in utils.lib.mkFlake {
inherit self inputs;
hostDefaults.modules = [
2023-04-11 16:50:37 +07:00
./modules/vfio.nix
./modules/ccache.nix
./modules/impermanence.nix
2023-05-13 20:32:35 +07:00
./modules/common.nix
2023-05-11 17:28:47 +07:00
impermanence.nixosModule
2023-01-24 02:24:40 +07:00
];
2023-05-17 07:16:03 +07:00
hosts = builtins.mapAttrs (_: mkHost) {
nixmsi = {
2023-01-24 02:24:40 +07:00
modules = [
nix-gaming.nixosModules.pipewireLowLatency
2023-05-17 07:16:03 +07:00
./hardware/msi_delta_15.nix
./hosts/nixmsi.nix
2023-05-11 05:33:08 +07:00
] ++ common "nixmsi";
};
2023-05-17 07:16:03 +07:00
nixserver = {
2023-05-11 05:33:08 +07:00
modules = [
nixos-mailserver.nixosModules.default
2023-05-17 07:16:03 +07:00
./hardware/hp_probook_g0.nix
./hosts/nixserver
2023-05-11 05:33:08 +07:00
] ++ common "nixserver";
2023-01-24 02:24:40 +07:00
};
};
};
}