nixos-config/flake.nix

251 lines
8.6 KiB
Nix
Raw Normal View History

2020-08-04 01:46:48 +04:00
{
description = "System configuration";
inputs = {
2023-04-15 03:13:02 +03:00
flake-utils-plus.url = "github:AtaraxiaSjel/flake-utils-plus";
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";
2021-11-17 05:09:46 +03:00
nix.url = "github:nixos/nix";
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";
2022-04-22 02:15:29 +03:00
arkenfox-userjs = {
url = "github:arkenfox/user.js";
flake = false;
};
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-04-15 03:13:02 +03:00
cassowary.url = "github:AtaraxiaSjel/cassowary";
2023-03-27 20:57:06 +03:00
hyprland.url = "github:hyprwm/Hyprland";
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";
};
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-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
# pkgsFor = system:
# import inputs.nixpkgs {
# overlays = [ self.overlay ];
# localSystem = { inherit system; };
# config = {
# android_sdk.accept_license = true;
# };
# };
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-02-23 00:01:15 +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);
nixosProfiles = builtins.listToAttrs (findModules ./profiles);
nixosRoles = import ./roles;
2023-03-06 10:24:24 +03:00
sharedPatches = patchesPath [
"mullvad-exclude-containers.patch"
"ydotoold.patch"
"gitea-208605.patch"
"waydroid-1.4.0.patch"
2023-04-08 22:47:50 +03:00
"bitwarden-pr224092.patch"
2023-04-16 22:40:20 +03:00
"ivpn.patch"
"ivpn-ui.patch"
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
];
2022-10-01 22:49:29 +03:00
channelsConfig = { allowUnfree = true; };
channels.unstable.input = nixpkgs;
2023-01-26 00:32:35 +03:00
channels.unstable.patches = patchesPath [ ] ++ sharedPatches;
2022-10-01 22:49:29 +03:00
channels.unstable-zfs.input = nixpkgs;
2023-01-26 00:32:35 +03:00
channels.unstable-zfs.patches = patchesPath [ "zen-kernels.patch" ] ++ sharedPatches;
2022-10-01 22:49:29 +03:00
hostDefaults.system = "x86_64-linux";
hostDefaults.channelName = "unstable";
hosts = with nixpkgs.lib; let
hostnames = builtins.attrNames (builtins.readDir ./machines);
mkHost = name: let
2022-10-01 22:49:29 +03:00
system = builtins.readFile (./machines + "/${name}/system");
# pkgs = pkgsFor system;
in {
inherit system;
modules = __attrValues self.customModules ++ [
(import (./machines + "/${name}"))
# { nixpkgs.pkgs = pkgs; }
{ 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; };
};
in (genAttrs hostnames mkHost) // {
2022-10-08 04:32:18 +03:00
AMD-Workstation = {
2023-01-26 00:08:39 +03:00
system = builtins.readFile (./machines/AMD-Workstation/system);
modules = __attrValues self.customModules ++ [
(import (./machines/AMD-Workstation))
{ device = "AMD-Workstation"; mainuser = "ataraxia"; }
2023-03-23 01:51:53 +03:00
inputs.vscode-server.nixosModule
];
2023-01-26 00:32:35 +03:00
specialArgs = { inherit inputs; };
2023-03-25 19:31:05 +03:00
channelName = "unstable-zfs";
2023-01-26 00:32:35 +03:00
};
2023-04-16 18:59:54 +03:00
Dell-Laptop = {
system = builtins.readFile (./machines/Dell-Laptop/system);
modules = __attrValues self.customModules ++ [
(import (./machines/Dell-Laptop))
{ device = "Dell-Laptop"; mainuser = "ataraxia"; }
inputs.vscode-server.nixosModule
];
specialArgs = { inherit inputs; };
channelName = "unstable-zfs";
};
2023-02-23 00:01:15 +03:00
Flakes-ISO = {
system = "x86_64-linux";
2023-04-16 18:59:54 +03:00
modules = [
(import (./machines/Flakes-ISO))
{ device = "Flakes-ISO"; mainuser = "ataraxia"; }
2023-02-23 00:01:15 +03:00
./machines/Home-Hypervisor/autoinstall.nix
2023-03-25 19:31:05 +03:00
./machines/AMD-Workstation/autoinstall.nix
2023-04-16 18:59:54 +03:00
./machines/Dell-Laptop/autoinstall.nix
2023-02-23 00:01:15 +03:00
./machines/NixOS-VM/autoinstall.nix
2023-04-16 18:59:54 +03:00
self.customModules.autoinstall
2023-02-23 00:01:15 +03:00
];
specialArgs = { inherit inputs; };
};
Flakes-ISO-Aarch64 = {
system = "aarch64-linux";
modules = __attrValues self.customModules ++ [
2023-03-25 19:31:05 +03:00
(import (./machines/Flakes-ISO)) { device = "Flakes-ISO-Aarch64"; mainuser = "ataraxia"; }
2023-02-23 00:01:15 +03:00
./machines/Arch-Builder-VM/autoinstall.nix
];
specialArgs = { inherit inputs; };
};
2022-10-01 22:49:29 +03:00
};
outputsBuilder = channels: let
pkgs = channels.unstable;
2022-12-07 22:05:00 +03:00
pkgs-zfs = channels.unstable-zfs;
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}"
elif [[ $1 = "iso" ]]; then
2022-10-06 00:42:09 +03:00
shift
2022-09-29 18:53:46 +03:00
nix build .#nixosConfigurations.Flakes-ISO.config.system.build.isoImage "$@"
2021-10-25 23:41:09 +03:00
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-01-26 00:32:35 +03:00
devShells.default = channels.unstable.mkShell {
2022-10-01 22:49:29 +03:00
name = "aliases";
2023-01-26 00:08:39 +03:00
packages = with pkgs; [
rebuild update-vscode upgrade upgrade-hyprland
2023-01-26 02:12:00 +03:00
nixfmt nixpkgs-fmt statix vulnix deadnix
2023-01-26 00:08:39 +03:00
];
2022-10-01 22:49:29 +03:00
};
packages = {
Wayland-VM = nixos-generators.nixosGenerate {
system = builtins.readFile (./machines/Wayland-VM/system);
modules = __attrValues self.customModules ++ [
(import (./machines/Wayland-VM))
{ device = "Wayland-VM"; mainuser = "ataraxia"; }
];
2022-10-01 22:49:29 +03:00
specialArgs = { inherit inputs; };
format = "vm";
};
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";
modules = __attrValues self.customModules ++ [
(import (./machines/Flakes-ISO))
{ device = "Flakes-ISO"; mainuser = "ataraxia"; }
2023-02-14 07:04:20 +03:00
./machines/Home-Hypervisor/autoinstall.nix
2023-02-23 00:01:15 +03:00
./machines/NixOS-VM/autoinstall.nix
2023-02-14 07:04:20 +03:00
];
specialArgs = { inherit inputs; };
format = "install-iso";
};
Flakes-ISO-Aarch64 = nixos-generators.nixosGenerate {
system = "aarch64-linux";
modules = __attrValues self.customModules ++ [
(import (./machines/Flakes-ISO))
{ device = "Flakes-ISO-Aarch64"; mainuser = "ataraxia"; }
2023-02-14 07:04:20 +03:00
./machines/Arch-Builder-VM/autoinstall.nix
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
};
2022-10-01 22:49:29 +03:00
};
2020-08-04 01:46:48 +04:00
}