nixos-config/flake.nix

544 lines
17 KiB
Nix
Raw Normal View History

2021-09-24 06:09:20 +02:00
{
inputs = {
2023-04-29 23:29:05 +02:00
2024-04-17 21:30:19 +02:00
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
2024-06-02 20:50:17 +02:00
clan-fact-generators = {
url = "github:mrvandalo/clan-fact-generators";
inputs.clan-core.follows = "clan-core";
};
2024-04-17 21:30:19 +02:00
clan-core = {
2024-05-29 21:54:53 +02:00
url = "git+https://git.clan.lol/clan/clan-core";
2024-06-02 21:38:48 +02:00
#url = "git+file:///home/palo/dev/clan-core";
2024-04-17 21:30:19 +02:00
inputs.nixpkgs.follows = "nixpkgs"; # Needed if your configuration uses nixpkgs unstable.
inputs.flake-parts.follows = "flake-parts";
};
2024-05-24 19:04:21 +02:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
2024-06-19 13:19:46 +02:00
nixpkgs-unstable-small.url = "github:nixos/nixpkgs/nixos-unstable-small";
2024-05-24 19:04:21 +02:00
nixpkgs-legacy_2211.url = "github:nixos/nixpkgs/nixos-22.11";
nixpkgs-legacy_2311.url = "github:nixos/nixpkgs/nixos-23.11";
2024-06-14 10:19:17 +02:00
nixpkgs-legacy_2405.url = "github:nixos/nixpkgs/nixos-24.05";
2023-06-30 00:14:18 +02:00
nixos-hardware.url = "github:nixos/nixos-hardware";
2024-02-26 09:44:59 +01:00
nixos-anywhere.url = "github:nix-community/nixos-anywhere";
2023-06-29 10:08:09 +02:00
home-manager = {
2024-05-24 21:08:34 +02:00
#url = "github:nix-community/home-manager/release-23.11";
url = "github:nix-community/home-manager";
#inputs.nixpkgs.follows = "nixpkgs";
2023-06-29 10:08:09 +02:00
};
2024-05-30 16:38:33 +02:00
polygon-art = {
url = "git+https://git.ingolf-wagner.de/palo/polygon-art.git";
};
2024-05-30 16:38:33 +02:00
home-manager-utils = {
url = "github:mrvandalo/home-manager-utils";
inputs.home-manager.follows = "home-manager";
};
2024-05-30 16:38:33 +02:00
2022-12-18 16:46:20 +01:00
permown = {
2022-12-18 17:29:16 +01:00
url = "github:mrVanDalo/module.permown";
2022-12-18 16:46:20 +01:00
#url = "git+file:///home/palo/dev/nixos/permown";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-05-30 16:38:33 +02:00
2022-06-22 23:06:16 +02:00
private_assets = {
2024-06-05 15:10:28 +02:00
#url = "git+file:///home/palo/dev/nixos/nixos-private-assets";
url = "git+ssh://forgejo@git.ingolf-wagner.de/palo/nixos-private-assets.git?ref=main";
flake = true;
2022-06-22 23:06:16 +02:00
};
2024-05-30 16:38:33 +02:00
2022-09-29 12:36:36 +02:00
retiolum = {
2023-02-16 21:43:28 +01:00
url = "github:Mic92/retiolum";
#url = "git+file:///home/palo/dev/nixos/retiolum";
2022-09-29 12:36:36 +02:00
};
2024-05-30 16:38:33 +02:00
2024-02-16 22:21:05 +01:00
srvos.url = "github:nix-community/srvos";
2024-05-30 16:38:33 +02:00
2024-08-29 03:25:41 +02:00
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
2022-11-24 13:48:18 +01:00
landingpage = {
#url = "git+file:///home/palo/dev/landingpage";
url = "github:mrVanDalo/landingpage";
2022-10-22 15:01:11 +02:00
};
2024-05-30 16:38:33 +02:00
# todo: mabye use https://github.com/jtroo/kanata instead
# fixme: kmonad crashes every now and than and the keyboard is not usable anymore.
2023-02-17 11:45:09 +01:00
kmonad = {
url = "github:kmonad/kmonad?dir=nix";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-05-30 16:38:33 +02:00
2023-07-17 09:47:42 +02:00
stylix = {
2024-05-24 21:08:34 +02:00
url = "github:danth/stylix";
2024-01-02 03:41:35 +01:00
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
2023-07-17 09:47:42 +02:00
};
2024-05-30 16:38:33 +02:00
# smoke test framwork to trigger tests (enable if I want to use it for real)
#smoke = {
# url = github:SamirTalwar/smoke;
# inputs.nixpkgs.follows = "nixpkgs";
#};
# had to override it to remove colors
2023-11-17 15:13:46 +01:00
taskshell = {
url = "github:mrvandalo/taskshell";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-05-30 16:38:33 +02:00
2021-09-24 06:09:20 +02:00
};
outputs =
2024-08-29 03:25:41 +02:00
inputs@{
self,
clan-core,
clan-fact-generators,
flake-parts,
home-manager,
home-manager-utils,
kmonad,
landingpage,
nixos-anywhere,
nixos-hardware,
nixpkgs,
nixpkgs-legacy_2211,
nixpkgs-legacy_2311,
nixpkgs-legacy_2405,
nixpkgs-unstable-small,
permown,
polygon-art,
private_assets,
retiolum,
srvos,
stylix,
taskshell,
treefmt-nix,
}:
2024-04-17 21:30:19 +02:00
2021-09-25 20:28:25 +02:00
let
2024-04-17 21:30:19 +02:00
#system = "x86_64-linux";
2023-06-30 00:14:18 +02:00
2024-04-17 21:30:19 +02:00
#pkgs = nixpkgs.legacyPackages.${system};
2023-06-30 00:14:18 +02:00
inherit (nixpkgs) lib;
2024-04-17 21:30:19 +02:00
meta = rec {
2023-06-30 00:14:18 +02:00
system = "x86_64-linux";
2024-04-17 21:30:19 +02:00
pkgs = import nixpkgs {
2023-06-30 00:14:18 +02:00
inherit system;
config.allowUnfree = true;
2023-07-01 17:34:23 +02:00
config.permittedInsecurePackages = [
2024-05-24 21:08:34 +02:00
"electron-24.8.6" # for bitwarden
2023-07-01 17:34:23 +02:00
"python-2.7.18.6"
2023-12-08 21:27:13 +01:00
"python-2.7.18.7"
2024-05-24 21:08:34 +02:00
"python-2.7.18.8"
2024-06-15 19:47:24 +02:00
"electron-27.3.11" # for logseq
2024-06-26 03:00:17 +02:00
"electron-28.3.3" # for logseq
2023-07-01 17:34:23 +02:00
];
2023-06-30 00:14:18 +02:00
overlays = [
(_self: _super: {
2024-06-19 13:19:46 +02:00
unstable-small = import nixpkgs-unstable-small {
inherit system;
config.allowUnfree = true;
};
legacy_2211 = import nixpkgs-legacy_2211 {
inherit system;
config.allowUnfree = true;
};
legacy_2311 = import nixpkgs-legacy_2311 {
2023-06-30 00:14:18 +02:00
inherit system;
config.allowUnfree = true;
};
2024-06-14 10:19:17 +02:00
legacy_2405 = import nixpkgs-legacy_2405 {
inherit system;
config.allowUnfree = true;
};
2023-06-30 11:02:05 +02:00
polygon-art = polygon-art.packages.${system};
landingpage = landingpage.packages.${system}.plain;
kmonad = kmonad.packages.${system}.kmonad;
2023-11-17 15:13:46 +01:00
tasksh = taskshell.packages.${system}.tasksh;
2024-06-28 11:30:37 +02:00
pkl = self.packages.${system}.pkl;
2023-06-30 00:14:18 +02:00
})
2024-06-07 22:56:52 +02:00
(import ./pkgs)
2022-06-23 00:33:59 +02:00
];
};
2023-06-30 00:14:18 +02:00
specialArgs = {
2024-08-28 01:02:37 +02:00
inherit inputs;
2024-06-07 22:56:52 +02:00
assets = ./assets;
factsGenerator = clan-fact-generators.lib { inherit pkgs; };
2024-08-29 03:25:41 +02:00
clanLib = import ./lib/clanlib.nix {
inherit (pkgs) lib;
machineDir = ./machines;
};
2024-07-20 13:56:03 +02:00
zerotierDeviceName = "ztbn67ogn2";
2024-07-24 00:55:55 +02:00
components = ./components;
2024-08-08 16:39:50 +02:00
features = ./features;
2023-06-30 00:14:18 +02:00
};
2024-04-17 21:30:19 +02:00
};
2023-06-30 11:02:05 +02:00
2024-04-17 21:30:19 +02:00
clanSetup =
2024-08-29 03:25:41 +02:00
{
name,
host,
modules,
}:
{
2024-04-17 21:30:19 +02:00
clan.core.networking.targetHost = lib.mkDefault "root@${host}";
2024-04-17 21:30:19 +02:00
nixpkgs.pkgs = meta.pkgs;
nixpkgs.hostPlatform = meta.system;
2024-06-19 13:19:46 +02:00
clan.core.facts.secretStore = "password-store";
2024-05-29 20:16:04 +02:00
2024-08-29 03:25:41 +02:00
imports =
modules
++ defaultModules
++ [
./machines/${name}/configuration.nix
];
2023-06-30 11:02:05 +02:00
};
2024-08-29 03:25:41 +02:00
zerotierControllerModule = {
clan.core.networking.zerotier.controller = {
enable = true;
public = false;
2024-06-26 01:25:55 +02:00
};
};
2024-08-29 03:25:41 +02:00
zerotierModules =
{ pkgs, ... }:
{
imports = [
# this magically adds all my machines in the zero tier network
# and makes the controller accept them.
# will automatic look into `/machines/<name>/facts/zerotier-ip
inputs.clan-core.clanModules.zerotier-static-peers
# Statically configure the host names of machines based on their respective zerotier-ip.
inputs.clan-core.clanModules.static-hosts
# generate ssh host keys with facts
inputs.clan-core.clanModules.sshd
# manual configs
{
clan.static-hosts.topLevelDomain = "bear";
components.network.zerotier.enable = true;
environment.systemPackages = [
clan-core.packages.${pkgs.system}.clan-cli
(pkgs.writers.writeBashBin "zerotier-script-nodeid" ''
sudo ${pkgs.zerotierone}/bin/zerotier-cli info | cut -d " " -f 3
'')
];
}
];
};
2023-06-30 00:14:18 +02:00
defaultModules = [
2024-05-30 16:38:33 +02:00
# make flake inputs accessiable in NixOS
2023-06-30 11:02:05 +02:00
{
_module.args.self = self;
_module.args.inputs = self.inputs;
}
2024-05-31 22:02:52 +02:00
# ssh keys
2024-08-29 03:25:41 +02:00
(
{ config, ... }:
{
users.users.root.openssh.authorizedKeys.keyFiles = [
# master key
./assets/mrvandalo_rsa.pub
# backup key
"${config.clan.core.clanDir}/machines/chungus/facts/ssh.syncoid.id_ed25519.pub"
"${config.clan.core.clanDir}/machines/chungus/facts/ssh.rbackup.id_ed25519.pub"
];
}
)
{
# disable emergency mode everywhere, although it might be needed on laptops
boot.initrd.systemd.emergencyAccess = false;
boot.initrd.systemd.suppressedUnits = [
"emergency.service"
"emergency.target"
];
systemd.enableEmergencyMode = false;
}
2024-05-30 16:38:33 +02:00
# configure nix
2024-08-29 03:25:41 +02:00
(
{
pkgs,
lib,
clanLib,
...
}:
2024-05-27 10:48:38 +02:00
{
2024-08-07 23:08:28 +02:00
nix.settings.substituters = [ "http://cache.orbi.wg0" ];
nix.settings.trusted-public-keys = [ (clanLib.readFact "nix-serve.pub" "orbi") ];
2024-08-29 03:25:41 +02:00
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
2024-05-29 10:05:07 +02:00
nix.settings.max-jobs = 1;
2024-04-17 21:30:19 +02:00
# no channesl needed this way
2024-05-27 10:48:38 +02:00
nix.nixPath = [ "nixpkgs=${pkgs.path}" ];
# documentation
# =============
2024-06-07 07:54:43 +02:00
documentation.nixos.enable = true;
#documentation.nixos.includeAllModules = true; # fixme : not working (see down there)
documentation.nixos.options.warningsAreErrors = false; # todo make this true again
documentation.nixos.extraModules = [
./components
2024-08-08 16:39:50 +02:00
./features
#./modules
inputs.clan-core.nixosModules.clanCore
2024-08-27 15:30:09 +02:00
{
clan.core.clanDir = ./.; # fixes issues with clanCore https://git.clan.lol/clan/clan-core/issues/1979
}
# inputs.stylix.nixosModules.stylix # fixme: not working
permown.nixosModules.permown
kmonad.nixosModules.default
home-manager.nixosModules.home-manager
# retiolum.nixosModules.retiolum # fixme: not working
];
boot.loader.systemd-boot.configurationLimit = lib.mkDefault 10;
boot.loader.generic-extlinux-compatible.configurationLimit = lib.mkDefault 10;
boot.loader.grub.configurationLimit = lib.mkDefault 10;
2024-08-29 03:25:41 +02:00
}
)
2024-08-08 16:39:50 +02:00
# My Structure
./components
./features
./modules # todo : spread this across features and components
#./system/all # todo : spread this across features and components
2024-05-30 16:38:33 +02:00
# some modules I always use
permown.nixosModules.permown
kmonad.nixosModules.default
# some default things I always want
2024-08-29 03:25:41 +02:00
(
{ pkgs, ... }:
{
boot.tmp.useTmpfs = lib.mkDefault true;
environment.systemPackages = [
pkgs.nixpkgs-fmt
];
}
)
2023-06-30 00:14:18 +02:00
];
2024-08-29 03:25:41 +02:00
stylixModules =
{ pkgs, config, ... }:
{
imports = [ stylix.nixosModules.stylix ];
stylix.enable = true;
stylix.base16Scheme = "${pkgs.base16-schemes}/share/themes/gruvbox-light-medium.yaml";
stylix.image = ./assets/wallpaper.png;
stylix.fonts = {
serif = {
package = pkgs.nerdfonts.override { fonts = [ "Ubuntu" ]; };
name = "Ubuntu";
};
sansSerif = {
package = pkgs.nerdfonts.override { fonts = [ "Ubuntu" ]; };
name = "Ubuntu";
};
monospace = {
package = pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; };
name = "JetBrains Mono";
};
emoji = {
package = pkgs.noto-fonts-emoji;
name = "Noto Color Emoji";
};
sizes.popups = 15;
};
};
2023-07-01 00:20:03 +02:00
2024-08-29 03:25:41 +02:00
homeManagerModules =
{ pkgs, config, ... }:
{
imports = [
home-manager.nixosModules.home-manager
];
home-manager.extraSpecialArgs = {
#inherit private_assets;
assets = ./assets;
};
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.backupFileExtension = "backup";
home-manager.sharedModules = [
home-manager-utils.hmModule
];
2024-04-21 21:15:45 +02:00
};
2023-02-13 18:40:56 +01:00
2023-06-30 00:14:18 +02:00
in
2023-01-31 15:28:24 +01:00
2024-08-29 03:25:41 +02:00
flake-parts.lib.mkFlake { inherit inputs; } (
{ self, pkgs, ... }:
{
# We define our own systems below. you can still use this to add system specific outputs to your flake.
# See: https://flake.parts/getting-started
systems = [ "x86_64-linux" ];
2024-04-17 21:30:19 +02:00
2024-08-29 03:25:41 +02:00
# import clan-core modules
imports = [
clan-core.flakeModules.default
./nix/formatter.nix
];
2024-04-17 21:30:19 +02:00
2024-08-29 03:25:41 +02:00
perSystem =
{ pkgs, ... }:
{
packages.pkl = pkgs.callPackage ./pkgs/pkl { };
2023-07-01 17:34:23 +02:00
};
2024-05-28 17:01:27 +02:00
2024-08-29 03:25:41 +02:00
# Define your clan
clan = {
# Clan wide settings.
meta.name = "gummybears"; # Ensure to choose a unique name.
specialArgs = meta.specialArgs;
machines = {
cream = clanSetup {
name = "cream";
host = "cream.bear";
modules = [
zerotierModules
nixos-hardware.nixosModules.framework-12th-gen-intel
retiolum.nixosModules.retiolum
private_assets.nixosModules.cream
private_assets.nixosModules.yubikey
homeManagerModules
stylixModules
{ home-manager.users.mainUser.gui.enable = true; }
{
home-manager.users.mainUser = import ./homes/palo;
home-manager.users.root = import ./homes/root;
}
{
clan.core.machineDescription = "Laptop";
}
];
};
cherry = clanSetup {
name = "cherry";
host = "cherry.bear";
modules = [
zerotierModules
nixos-hardware.nixosModules.framework-13th-gen-intel
retiolum.nixosModules.retiolum
private_assets.nixosModules.yubikey
private_assets.nixosModules.cherry
homeManagerModules
stylixModules
{ home-manager.users.mainUser.gui.enable = true; }
{
home-manager.users.mainUser = import ./homes/palo;
home-manager.users.root = import ./homes/root;
}
{
clan.core.machineDescription = "Laptop";
}
];
};
chungus = clanSetup {
name = "chungus";
host = "chungus.bear";
modules = [
zerotierModules
zerotierControllerModule
homeManagerModules
stylixModules
retiolum.nixosModules.retiolum
private_assets.nixosModules.chungus
{
home-manager.users.mainUser = import ./homes/palo;
home-manager.users.root = import ./homes/root;
}
{
clan.core.machineDescription = "Home Server";
}
];
};
orbi = clanSetup {
name = "orbi";
host = "orbi.bear";
#host = "95.216.66.212";
modules = [
homeManagerModules
stylixModules
zerotierModules
srvos.nixosModules.hardware-hetzner-online-intel
#srvos.nixosModules.server
#srvos.nixosModules.mixins-terminfo
{
home-manager.users.mainUser = import ./homes/palo;
home-manager.users.root = import ./homes/root;
}
{
clan.core.machineDescription = "Internet Server";
}
];
};
probe = clanSetup {
name = "probe";
#host = "167.235.205.150";
host = "95.217.18.54";
modules = [
homeManagerModules
stylixModules
srvos.nixosModules.hardware-hetzner-cloud
srvos.nixosModules.server
srvos.nixosModules.mixins-terminfo
#inputs.clan-core.clanModules.sshd
{
home-manager.users.mainUser = import ./homes/palo;
home-manager.users.root = import ./homes/root;
}
{
clan.core.machineDescription = "Dummy Internet Server";
}
];
};
usbstick = clanSetup {
name = "usbstick";
#host = "usbstick.bear";
host = "10.100.0.100";
modules = [
homeManagerModules
stylixModules
zerotierModules
{ home-manager.users.mainUser.gui.enable = true; }
{
home-manager.users.mainUser = import ./homes/palo;
home-manager.users.root = import ./homes/root;
}
{
clan.core.machineDescription = "USB-Stick for Backup";
}
];
};
2024-06-21 22:33:32 +02:00
2024-08-08 23:44:25 +02:00
};
};
2024-04-17 21:30:19 +02:00
2024-08-29 03:25:41 +02:00
}
);
2024-04-17 21:30:19 +02:00
2021-09-24 06:09:20 +02:00
}