nixos-config/flake.nix

254 lines
8.4 KiB
Nix
Raw Normal View History

2020-08-04 01:46:48 +04:00
{
description = "System configuration";
inputs = {
2023-10-13 19:43:02 +03:00
flake-utils-plus.url = "github:gytis-ivaskevicius/flake-utils-plus/v1.4.0";
2022-07-02 19:30:20 +03:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
2021-09-15 23:17:00 +03:00
nixpkgs-master.url = "github:nixos/nixpkgs/master";
2023-06-23 18:27:46 +03:00
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.05";
2022-12-07 22:05:00 +03:00
flake-registry = {
url = "github:nixos/flake-registry";
flake = false;
};
2021-09-28 01:37:20 +03:00
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-01-26 00:38:13 +03:00
impermanence.url = "github:AtaraxiaSjel/impermanence";
2023-08-30 18:38:17 +03:00
aagl.url = "github:ezKEa/aagl-gtk-on-nix";
2022-04-22 02:15:29 +03:00
arkenfox-userjs = {
url = "github:arkenfox/user.js";
flake = false;
};
2023-06-13 23:11:47 +03:00
attic.url = "github:zhaofengli/attic";
2023-04-15 03:13:02 +03:00
base16.url = "github:AtaraxiaSjel/base16-nix";
2021-09-28 01:37:20 +03:00
base16-tokyonight-scheme = {
2023-04-15 03:13:02 +03:00
url = "github:AtaraxiaSjel/base16-tokyonight-scheme";
2020-08-04 01:46:48 +04:00
flake = false;
};
2023-05-02 23:12:53 +03:00
cassowary = {
url = "github:AtaraxiaSjel/cassowary";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-06-23 18:27:46 +03:00
deploy-rs.url = "github:serokell/deploy-rs";
2023-08-05 07:41:59 +03:00
devenv.url = "github:cachix/devenv";
2023-06-23 18:27:46 +03:00
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-10-01 23:45:11 +03:00
hyprland = {
url = "github:hyprwm/Hyprland";
inputs.nixpkgs.follows = "nixpkgs"; # MESA/OpenGL HW workaround
};
2023-01-26 00:32:35 +03:00
hyprpaper = {
url = "github:hyprwm/hyprpaper";
2022-08-05 21:10:22 +03:00
inputs.nixpkgs.follows = "nixpkgs";
};
2023-07-26 21:19:30 +03:00
mms.url = "github:mkaito/nixos-modded-minecraft-servers";
2022-01-29 00:41:41 +03:00
nix-alien = {
url = "github:thiagokokada/nix-alien";
inputs.nixpkgs.follows = "nixpkgs";
2021-09-28 01:37:20 +03:00
};
2022-12-07 22:05:00 +03:00
nix-direnv.url = "github:nix-community/nix-direnv";
2023-10-13 19:52:54 +03:00
nix-fast-build = {
url = "github:Mic92/nix-fast-build";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-02-22 23:57:37 +03:00
nix-vscode-marketplace = {
url = "github:nix-community/nix-vscode-extensions";
inputs.nixpkgs.follows = "nixpkgs";
};
2022-08-31 01:13:53 +03:00
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-01-26 02:12:00 +03:00
nur.url = "github:nix-community/NUR";
2023-03-06 10:24:24 +03:00
prismlauncher.url = "github:AtaraxiaSjel/PrismLauncher/develop";
2022-12-07 22:10:49 +03:00
rnix-lsp = {
url = "github:nix-community/rnix-lsp";
inputs.nixpkgs.follows = "nixpkgs";
};
2021-06-16 05:30:04 +03:00
rycee = {
2021-09-15 23:17:00 +03:00
url = "gitlab:rycee/nur-expressions";
2021-06-16 05:30:04 +03:00
flake = false;
};
2021-10-30 21:04:53 +03:00
simple-nixos-mailserver = {
url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-03-23 01:51:53 +03:00
vscode-server = {
url = "github:msteen/nixos-vscode-server";
2021-11-12 05:30:35 +03:00
inputs.nixpkgs.follows = "nixpkgs";
};
2020-08-04 01:46:48 +04:00
};
2023-03-27 20:57:06 +03:00
outputs = { self, nixpkgs, nixos-generators, flake-utils-plus, ... }@inputs:
2022-10-01 22:49:29 +03:00
let
findModules = dir:
builtins.concatLists (builtins.attrValues (builtins.mapAttrs
(name: type:
if type == "regular" then
[{
name = builtins.elemAt (builtins.match "(.*)\\.nix" name) 0;
value = dir + "/${name}";
}]
else if (builtins.readDir (dir + "/${name}"))
? "default.nix" then [{
inherit name;
value = dir + "/${name}";
}] else
findModules (dir + "/${name}"))
(builtins.readDir dir)));
2023-01-26 00:08:39 +03:00
2023-01-26 02:12:00 +03:00
patchesPath = map (x: ./patches + "/${x}");
2023-01-26 00:08:39 +03:00
in flake-utils-plus.lib.mkFlake rec {
2022-10-01 22:49:29 +03:00
inherit self inputs;
2023-05-24 21:20:43 +03:00
supportedSystems = [
"x86_64-linux"
# "aarch64-linux"
];
2022-10-01 22:49:29 +03:00
2023-04-16 18:59:54 +03:00
customModules = builtins.listToAttrs (findModules ./modules);
2023-10-13 19:43:02 +03:00
customProfiles = builtins.listToAttrs (findModules ./profiles);
customRoles = import ./roles;
2023-04-16 18:59:54 +03:00
2023-03-06 10:24:24 +03:00
sharedPatches = patchesPath [
2023-04-25 17:20:58 +03:00
"vaultwarden.patch"
2023-04-25 17:27:42 +03:00
"webhooks.patch"
2023-03-06 10:24:24 +03:00
];
2023-10-13 19:43:02 +03:00
sharedOverlays = [ flake-utils-plus.overlay ];
channelsConfig = { allowUnfree = true; android_sdk.accept_license = true; };
2022-10-01 22:49:29 +03:00
channels.unstable.input = nixpkgs;
2023-10-01 23:45:11 +03:00
channels.unstable.patches = patchesPath [ "zen-kernels.patch" "ydotoold.patch" ] ++ sharedPatches;
2023-06-23 18:27:46 +03:00
channels.stable.input = inputs.nixpkgs-stable;
channels.stable.patches = sharedPatches;
2022-10-01 22:49:29 +03:00
hostDefaults.system = "x86_64-linux";
hostDefaults.channelName = "unstable";
hosts = with nixpkgs.lib; let
2023-11-16 04:01:47 +03:00
hostnames =
filter (n: (builtins.match ".*(ISO|VM)" n) == null)
(builtins.attrNames (builtins.readDir ./machines));
2023-10-13 19:43:02 +03:00
mkHost = name: {
2022-10-01 22:49:29 +03:00
system = builtins.readFile (./machines + "/${name}/system");
2023-11-11 03:10:45 +03:00
modules = __attrValues self.customModules ++ [
(import (./machines + "/${name}"))
{ device = name; mainuser = "ataraxia"; }
2023-03-25 19:31:05 +03:00
inputs.vscode-server.nixosModule
];
2022-10-01 22:49:29 +03:00
specialArgs = { inherit inputs; };
};
2023-06-23 18:27:46 +03:00
in (genAttrs hostnames mkHost) // {
NixOS-VPS = {
system = builtins.readFile (./machines/NixOS-VPS/system);
modules = [
(import (./machines/NixOS-VPS))
{ device = "NixOS-VPS"; mainuser = "ataraxia"; }
];
specialArgs = { inherit inputs; };
channelName = "stable";
};
};
2022-10-01 22:49:29 +03:00
2023-11-16 04:01:47 +03:00
nixosHostsCI = builtins.listToAttrs (map (name: {
inherit name;
value = self.nixosConfigurations."${name}".config.system.build.toplevel;
}) (builtins.attrNames self.nixosConfigurations));
2022-10-01 22:49:29 +03:00
outputsBuilder = channels: let
2023-06-15 23:17:03 +03:00
pkgs = channels.unstable;
2023-01-26 00:08:39 +03:00
# FIXME: nixos-rebuild with --flake flag doesn't work with doas
2022-10-01 22:49:29 +03:00
rebuild = pkgs.writeShellScriptBin "rebuild" ''
2021-10-25 23:41:09 +03:00
if [[ -z $1 ]]; then
echo "Usage: $(basename $0) {switch|boot|test}"
else
2022-12-07 22:13:34 +03:00
# doas nix-shell -p git --run "nixos-rebuild --flake . $@"
\sudo nixos-rebuild --flake . $@
2021-10-25 23:41:09 +03:00
fi
2022-10-01 22:49:29 +03:00
'';
update-vscode = pkgs.writeShellScriptBin "update-vscode" ''
2022-08-05 21:10:22 +03:00
./scripts/vscode_update_extensions.sh > ./profiles/applications/vscode/extensions.nix
2022-10-01 22:49:29 +03:00
'';
upgrade = pkgs.writeShellScriptBin "upgrade" ''
2022-08-05 21:10:22 +03:00
cp flake.lock flake.lock.bak && nix flake update
2022-12-07 22:05:00 +03:00
if [[ "$1" == "zfs" ]]; then
./scripts/gen-patch-zen.sh
fi
2022-10-01 22:49:29 +03:00
'';
2022-10-21 13:57:17 +03:00
upgrade-hyprland = pkgs.writeShellScriptBin "upgrade-hyprland" ''
2022-08-23 16:13:51 +03:00
cp flake.lock flake.lock.bak
nix flake lock --update-input hyprland
2022-10-01 22:49:29 +03:00
'';
2021-09-15 23:17:00 +03:00
in {
2023-06-15 22:06:44 +03:00
devShells = {
default = pkgs.mkShell {
name = "aliases";
packages = with pkgs; [
rebuild update-vscode upgrade upgrade-hyprland
2023-06-23 18:27:46 +03:00
nixfmt nixpkgs-fmt statix vulnix deadnix git deploy-rs
2023-10-13 19:43:02 +03:00
fup-repl
2023-06-15 22:06:44 +03:00
];
};
ci = pkgs.mkShell {
name = "ci";
packages = with pkgs; [
2023-11-17 00:01:18 +03:00
nix-eval-jobs jq
2023-06-15 22:06:44 +03:00
];
};
2022-10-01 22:49:29 +03:00
};
packages = {
2022-10-06 00:42:09 +03:00
Flakes-ISO = nixos-generators.nixosGenerate {
2023-02-14 07:04:20 +03:00
system = "x86_64-linux";
2023-05-24 21:20:43 +03:00
modules = [
(import (./machines/Flakes-ISO))
{ device = "Flakes-ISO"; mainuser = "ataraxia"; }
2023-02-14 07:04:20 +03:00
./machines/Home-Hypervisor/autoinstall.nix
2023-05-24 21:20:43 +03:00
./machines/AMD-Workstation/autoinstall.nix
./machines/Dell-Laptop/autoinstall.nix
self.customModules.autoinstall
2023-02-14 07:04:20 +03:00
];
specialArgs = { inherit inputs; };
format = "install-iso";
};
Flakes-ISO-Aarch64 = nixos-generators.nixosGenerate {
system = "aarch64-linux";
2023-05-24 21:20:43 +03:00
modules = [
(import (./machines/Flakes-ISO))
2023-05-24 21:20:43 +03:00
{ device = "Flakes-ISO"; mainuser = "ataraxia"; }
2023-02-14 07:04:20 +03:00
./machines/Arch-Builder-VM/autoinstall.nix
2023-05-24 21:20:43 +03:00
self.customModules.autoinstall
2023-01-26 00:08:39 +03:00
];
2022-10-06 00:42:09 +03:00
specialArgs = { inherit inputs; };
format = "install-iso";
};
2021-10-25 23:41:09 +03:00
};
2020-08-15 19:36:16 +04:00
};
2023-06-23 18:27:46 +03:00
deploy.nodes = let
pkgs = import nixpkgs { system = "x86_64-linux"; };
deployPkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [
inputs.deploy-rs.overlay
(self: super: { deploy-rs = { inherit (pkgs) deploy-rs; lib = super.deploy-rs.lib; }; })
];
};
2023-06-27 23:06:03 +03:00
mkDeploy = name: conf: conf // {
2023-06-23 18:27:46 +03:00
profiles.system = {
sshUser = "deploy";
user = "root";
fastConnection = true;
remoteBuild = false;
2023-06-27 23:06:03 +03:00
path = deployPkgs.deploy-rs.lib.activate.nixos self.nixosConfigurations.${name};
2023-06-23 18:27:46 +03:00
};
};
2023-06-27 23:06:03 +03:00
in builtins.mapAttrs mkDeploy {
2023-11-11 03:10:45 +03:00
NixOS-VPS = { hostname = "193.219.97.142"; };
2023-06-27 23:06:03 +03:00
Home-Hypervisor = { hostname = "192.168.0.10"; };
2023-11-11 03:10:45 +03:00
Dell-Laptop = { hostname = "192.168.0.101"; };
2023-06-23 18:27:46 +03:00
};
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib;
2022-10-01 22:49:29 +03:00
};
2020-08-04 01:46:48 +04:00
}