416 lines
12 KiB
Nix
416 lines
12 KiB
Nix
{
|
|
description = "Thor system configuration";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/release-22.11";
|
|
nixpkgs-u.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
home-manager = {
|
|
url = "github:nix-community/home-manager/release-22.11";
|
|
inputs = {
|
|
nixpkgs.follows = "nixpkgs";
|
|
utils.follows = "flake-utils";
|
|
};
|
|
};
|
|
|
|
agenix = {
|
|
url = "github:ryantm/agenix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
deploy-rs = {
|
|
url = "github:serokell/deploy-rs";
|
|
inputs = { nixpkgs.follows = "nixpkgs"; };
|
|
};
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
nixos-generators = {
|
|
url = "github:nix-community/nixos-generators";
|
|
inputs = { nixpkgs.follows = "nixpkgs"; };
|
|
};
|
|
nixos-hardware.url = "github:NixOS/nixos-hardware";
|
|
nix-rice = { url = "github:bertof/nix-rice/v0.3.1"; };
|
|
pre-commit-hooks = {
|
|
url = "github:cachix/pre-commit-hooks.nix";
|
|
inputs = {
|
|
nixpkgs.follows = "nixpkgs";
|
|
flake-utils.follows = "flake-utils";
|
|
};
|
|
};
|
|
tex2nix = {
|
|
url = "github:Mic92/tex2nix";
|
|
inputs = {
|
|
nixpkgs.follows = "nixpkgs";
|
|
flake-utils.follows = "flake-utils";
|
|
};
|
|
};
|
|
};
|
|
|
|
outputs =
|
|
{ self
|
|
, nixpkgs
|
|
, nixpkgs-u
|
|
, home-manager
|
|
, agenix
|
|
, deploy-rs
|
|
, flake-utils
|
|
, nixos-generators
|
|
, nixos-hardware
|
|
, nix-rice
|
|
, pre-commit-hooks
|
|
, tex2nix
|
|
}:
|
|
let
|
|
config = {
|
|
allowUnfree = true;
|
|
extraOptions = "experimental-features = nix-command flakes";
|
|
permittedInsecurePackages = [
|
|
"electron-9.4.4" # authy dependency
|
|
];
|
|
};
|
|
|
|
overlays = [
|
|
# Combine stable and unstable packages
|
|
(self: _: {
|
|
stable_pkgs = import nixpkgs {
|
|
inherit config overlays;
|
|
inherit (self) system;
|
|
};
|
|
unstable_pkgs = import nixpkgs-u {
|
|
inherit config overlays;
|
|
inherit (self) system;
|
|
};
|
|
inherit (tex2nix.packages.${self.system}) tex2nix;
|
|
})
|
|
|
|
# Nix rice
|
|
nix-rice.overlays.default
|
|
(import ./rice.nix)
|
|
|
|
# Flakes packages
|
|
(self: _: {
|
|
clipedit = self.callPackage ./custom/clipedit { };
|
|
update-background = self.callPackage ./custom/update-background {
|
|
backgrounds_directory = "$HOME/Immagini/Sfondi/1080+/1440+";
|
|
};
|
|
lockscreen = self.callPackage ./custom/lockscreen {
|
|
palette = self.rice.colorPalette;
|
|
font = self.rice.font.normal;
|
|
};
|
|
sddm-theme-clairvoyance =
|
|
self.callPackage ./custom/sddm-theme-clairvoyance {
|
|
wallpaper = ./wallpapers/comfy_waves.jpg;
|
|
};
|
|
sddm-sugar-dark = self.callPackage ./custom/sddm-sugar-dark { };
|
|
google-chrome = self.google-chrome.override {
|
|
commandLineArgs = [ "--password-store=gnome" "--force-dark-mode" ];
|
|
};
|
|
})
|
|
];
|
|
|
|
basic = with flake-utils.lib;
|
|
eachDefaultSystem (system:
|
|
let pkgs = import nixpkgs { inherit system config overlays; };
|
|
in {
|
|
formatter = pkgs.nixpkgs-fmt;
|
|
|
|
checks = {
|
|
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
|
src = ./.;
|
|
hooks = {
|
|
deadnix.enable = true;
|
|
nixpkgs-fmt.enable = true;
|
|
statix.enable = true;
|
|
};
|
|
};
|
|
};
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
buildInputs = [ deploy-rs.packages.${system}.deploy-rs ];
|
|
shellHook = ''
|
|
${self.checks.${system}.pre-commit-check.shellHook}
|
|
'';
|
|
LOCAL_KEY = "/etc/nix/key";
|
|
};
|
|
});
|
|
|
|
commonModules = [
|
|
# Nix configuration
|
|
{
|
|
nixpkgs = { inherit overlays config; };
|
|
nix = {
|
|
extraOptions = "experimental-features = nix-command flakes";
|
|
registry = {
|
|
stable = {
|
|
from = {
|
|
id = "stable";
|
|
type = "indirect";
|
|
};
|
|
flake = nixpkgs;
|
|
};
|
|
unstable = {
|
|
from = {
|
|
id = "unstable";
|
|
type = "indirect";
|
|
};
|
|
flake = nixpkgs-u;
|
|
};
|
|
};
|
|
};
|
|
}
|
|
|
|
# Home manager configuration
|
|
home-manager.nixosModules.default
|
|
{
|
|
home-manager = {
|
|
useGlobalPkgs = true;
|
|
useUserPackages = true;
|
|
};
|
|
}
|
|
agenix.nixosModules.default
|
|
{
|
|
# age.secrets.oauth_proxy_client_credentials.file = ./secrets/oauth_proxy_client_credentials.age;
|
|
age.secrets.spotify_password = {
|
|
file = ./secrets/spotify_password.age;
|
|
owner = "bertof";
|
|
};
|
|
}
|
|
|
|
./nixos_modules/bertof_user.nix
|
|
|
|
# Some defaults
|
|
{
|
|
services.fstrim.enable = true;
|
|
services.fwupd.enable = true;
|
|
}
|
|
./nixos_modules/btrfs_scrub.nix
|
|
./nixos_modules/distributed.nix
|
|
./nixos_modules/remote-deploy.nix
|
|
./nixos_modules/extended_registry.nix
|
|
./nixos_modules/automatic-garbage-collection.nix
|
|
./nixos_modules/automatic-upgrade.nix
|
|
./nixos_modules/zerotier.nix
|
|
];
|
|
|
|
installerModules = [
|
|
# Nix configuration
|
|
{
|
|
nixpkgs = { inherit overlays config; };
|
|
nix = {
|
|
extraOptions = "experimental-features = nix-command flakes";
|
|
registry = {
|
|
stable = {
|
|
from = {
|
|
id = "stable";
|
|
type = "indirect";
|
|
};
|
|
flake = nixpkgs;
|
|
};
|
|
unstable = {
|
|
from = {
|
|
id = "unstable";
|
|
type = "indirect";
|
|
};
|
|
flake = nixpkgs-u;
|
|
};
|
|
};
|
|
};
|
|
}
|
|
|
|
./nixos_modules/bertof_user.nix
|
|
./nixos_modules/distributed.nix
|
|
./nixos_modules/remote-deploy.nix
|
|
./nixos_modules/extended_registry.nix
|
|
./nixos_modules/zerotier.nix
|
|
./nixos_modules/installer.nix
|
|
];
|
|
|
|
thorConfig = {
|
|
nixosConfigurations = {
|
|
thor = nixpkgs.lib.nixosSystem {
|
|
system = "x86_64-linux";
|
|
modules = commonModules ++ [
|
|
./thor/hardware-configuration.nix
|
|
nixos-hardware.nixosModules.common-cpu-amd
|
|
nixos-hardware.nixosModules.common-pc-ssd
|
|
./thor/configuration.nix
|
|
|
|
./nixos_modules/pro_audio.nix
|
|
./nixos_modules/sesar.nix
|
|
./nixos_modules/pentablet.nix
|
|
./nixos_modules/steam-link.nix
|
|
./nixos_modules/kdeconnect.nix
|
|
|
|
{ home-manager.users.bertof = import ./thor/hm.nix; }
|
|
];
|
|
};
|
|
};
|
|
};
|
|
|
|
odinConfig = {
|
|
nixosConfigurations =
|
|
let
|
|
odinCommonModules = [
|
|
nixos-hardware.nixosModules.common-cpu-intel
|
|
nixos-hardware.nixosModules.common-pc-laptop
|
|
nixos-hardware.nixosModules.common-pc-laptop-ssd
|
|
./odin/hardware-configuration.nix
|
|
./odin/common_configuration.nix
|
|
|
|
./nixos_modules/pro_audio.nix
|
|
./nixos_modules/sesar.nix
|
|
./nixos_modules/pentablet.nix
|
|
./nixos_modules/steam-link.nix
|
|
./nixos_modules/kdeconnect.nix
|
|
|
|
{ home-manager.users.bertof = import ./odin/hm.nix; }
|
|
];
|
|
in
|
|
rec {
|
|
odin-nvidia = nixpkgs.lib.nixosSystem {
|
|
system = "x86_64-linux";
|
|
modules = commonModules ++ odinCommonModules
|
|
++ [ ./odin/configuration-nvidia.nix ];
|
|
};
|
|
|
|
odin-intel = nixpkgs.lib.nixosSystem {
|
|
system = "x86_64-linux";
|
|
modules = commonModules ++ odinCommonModules
|
|
++ [ ./odin/configuration-intel.nix ];
|
|
};
|
|
|
|
odin = odin-intel;
|
|
};
|
|
};
|
|
|
|
freyaConfig = {
|
|
nixosConfigurations = {
|
|
freya = nixpkgs.lib.nixosSystem {
|
|
system = "aarch64-linux";
|
|
modules = commonModules ++ [
|
|
nixos-hardware.nixosModules.raspberry-pi-4
|
|
# ./freya/hardware-configuration.nix
|
|
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
|
|
# ({nixosModules,...}: "${nixosModules}/installer/sd-card/sd-image-aarch64.nix")
|
|
./freya/configuration.nix
|
|
{ home-manager.users.bertof = import ./freya/hm.nix; }
|
|
({ lib, ... }: { boot.supportedFilesystems = lib.mkForce [ "btrfs" "reiserfs" "vfat" "f2fs" "xfs" "ntfs" "cifs" ]; })
|
|
];
|
|
};
|
|
};
|
|
};
|
|
|
|
baldurConfig = {
|
|
nixosConfigurations = {
|
|
baldur = nixpkgs.lib.nixosSystem {
|
|
system = "x86_64-linux";
|
|
modules = commonModules ++ [
|
|
# ./baldur/hardware-configuration.nix
|
|
./baldur/configuration.nix
|
|
"${nixpkgs}/nixos/modules/virtualisation/digital-ocean-config.nix"
|
|
./nixos_modules/digitalocean.nix
|
|
{ home-manager.users.bertof = import ./baldur/hm.nix; }
|
|
];
|
|
};
|
|
};
|
|
};
|
|
|
|
lokiConfig = {
|
|
nixosConfigurations = {
|
|
loki = nixpkgs.lib.nixosSystem {
|
|
system = "x86_64-linux";
|
|
modules = commonModules ++ [
|
|
nixos-hardware.nixosModules.common-cpu-intel
|
|
nixos-hardware.nixosModules.common-pc-ssd
|
|
./loki/hardware-configuration.nix
|
|
./loki/configuration.nix
|
|
{
|
|
home-manager.users.bertof = import ./loki/hm.nix;
|
|
home-manager.users.tiziano = import ./loki/hm_tiziano.nix;
|
|
}
|
|
];
|
|
};
|
|
};
|
|
};
|
|
|
|
deployments = {
|
|
# Deploy-rs checks
|
|
checks = builtins.mapAttrs
|
|
(_system: deployLib: deployLib.deployChecks self.deploy)
|
|
deploy-rs.lib;
|
|
|
|
# Map nodes to Deploy-rs deployments
|
|
deploy.nodes = {
|
|
thor = {
|
|
hostname = "thor.local";
|
|
profiles.system = {
|
|
user = "root";
|
|
path = deploy-rs.lib.x86_64-linux.activate.nixos
|
|
self.nixosConfigurations.thor;
|
|
};
|
|
};
|
|
|
|
odin = {
|
|
hostname = "odin.local";
|
|
profiles.system = {
|
|
user = "root";
|
|
path = deploy-rs.lib.x86_64-linux.activate.nixos
|
|
self.nixosConfigurations.odin;
|
|
};
|
|
};
|
|
|
|
loki = {
|
|
hostname = "loki.local";
|
|
profiles.system = {
|
|
user = "root";
|
|
path = deploy-rs.lib.x86_64-linux.activate.nixos
|
|
self.nixosConfigurations.loki;
|
|
};
|
|
};
|
|
|
|
baldur = {
|
|
hostname = "baldur.bertof.net";
|
|
profiles.system = {
|
|
user = "root";
|
|
path = deploy-rs.lib.x86_64-linux.activate.nixos
|
|
self.nixosConfigurations.baldur;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
images = with flake-utils.lib;
|
|
eachSystem [ system.x86_64-linux system.aarch64-linux ] (system: {
|
|
packages = {
|
|
# Installer ISO
|
|
install-iso = nixos-generators.nixosGenerate {
|
|
inherit system;
|
|
modules = installerModules;
|
|
format = "install-iso";
|
|
};
|
|
|
|
# Aarch64 base image
|
|
aarch64-base-image = nixos-generators.nixosGenerate {
|
|
system = flake-utils.lib.system.aarch64-linux;
|
|
modules = installerModules;
|
|
format = "sd-aarch64";
|
|
};
|
|
|
|
# Installer DigitalOcean
|
|
do-image = nixos-generators.nixosGenerate {
|
|
inherit system;
|
|
modules = installerModules;
|
|
format = "do";
|
|
};
|
|
};
|
|
});
|
|
|
|
in
|
|
builtins.foldl' nixpkgs.lib.recursiveUpdate { } [
|
|
basic
|
|
thorConfig
|
|
odinConfig
|
|
freyaConfig
|
|
baldurConfig
|
|
lokiConfig
|
|
deployments
|
|
images
|
|
];
|
|
}
|