dotfiles/system/flake.nix

80 lines
2.5 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
hw = nixos-hardware.nixosModules;
# 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) ];
2023-05-11 05:33:08 +07:00
extraArgs = {
inherit nixpkgs;
};
2023-05-11 17:28:47 +07:00
lib = nixpkgs.lib // {
quotePotentialIpV6 = addr:
if nixpkgs.lib.hasInfix ":" addr then "[${addr}]" else addr;
};
specialArgs = {
inherit lib;
};
mkHost = args @ { system ? "x86_64-linux", modules, ... }: {
inherit system extraArgs specialArgs;
} // 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
];
hosts = {
2023-05-11 17:28:47 +07:00
nixmsi = mkHost {
2023-01-24 02:24:40 +07:00
modules = [
./hosts/nixmsi.nix
nix-gaming.nixosModules.pipewireLowLatency
2023-01-24 02:24:40 +07:00
hw.common-pc-ssd # enables fstrim
hw.common-cpu-amd # microcode
hw.common-cpu-amd-pstate # amd-pstate
hw.common-gpu-amd # configures drivers
hw.common-pc-laptop # enables tlp
2023-05-11 05:33:08 +07:00
] ++ common "nixmsi";
};
2023-05-11 17:28:47 +07:00
nixserver = mkHost {
2023-05-11 05:33:08 +07:00
modules = [
./hosts/nixserver
nixos-mailserver.nixosModules.default
hw.common-pc-hdd
hw.common-cpu-intel
] ++ common "nixserver";
2023-01-24 02:24:40 +07:00
};
};
};
}