2021-05-19 23:08:18 +02:00
|
|
|
{
|
|
|
|
description = "Malte Tammena's system configuration";
|
|
|
|
|
2021-10-13 17:38:24 +02:00
|
|
|
inputs = {
|
2023-04-19 01:01:07 +02:00
|
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
|
|
devshell.url = "github:numtide/devshell";
|
|
|
|
treefmt-nix.url = "github:numtide/treefmt-nix";
|
2023-04-19 02:10:55 +02:00
|
|
|
pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix";
|
2023-04-19 01:01:07 +02:00
|
|
|
|
2021-10-13 17:38:24 +02:00
|
|
|
nixpkgs.url = "nixpkgs/nixos-unstable";
|
2022-03-23 13:10:18 +01:00
|
|
|
nixos-hardware.url = "github:NixOS/nixos-hardware";
|
|
|
|
custom-udev-rules.url = "github:MalteT/custom-udev-rules";
|
2022-06-05 14:16:32 +02:00
|
|
|
nix-colors.url = "github:Misterio77/nix-colors";
|
2022-03-23 13:10:18 +01:00
|
|
|
|
2021-12-26 21:49:18 +01:00
|
|
|
nixpkgs-wayland = {
|
|
|
|
url = "github:nix-community/nixpkgs-wayland";
|
|
|
|
};
|
|
|
|
mensa = {
|
2023-04-15 00:43:20 +02:00
|
|
|
url = "github:MalteT/mensa/main";
|
2021-12-26 21:49:18 +01:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
sops-nix = {
|
|
|
|
url = "github:Mic92/sops-nix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
home-manager = {
|
|
|
|
url = "github:nix-community/home-manager";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2022-03-23 13:10:18 +01:00
|
|
|
fend = {
|
|
|
|
url = "github:MalteT/fend/flake";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2022-03-25 18:46:53 +01:00
|
|
|
hydra = {
|
|
|
|
url = "github:NixOS/hydra";
|
|
|
|
};
|
2022-12-22 12:33:49 +01:00
|
|
|
hyprland = {
|
|
|
|
url = "github:hyprwm/Hyprland";
|
2023-04-16 14:18:47 +02:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
2022-12-22 12:33:49 +01:00
|
|
|
};
|
2023-07-12 21:11:25 +02:00
|
|
|
hyprland-contrib = {
|
|
|
|
url = "github:hyprwm/contrib";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2023-04-14 09:12:19 +02:00
|
|
|
xdg-desktop-portal-hyprland = {
|
|
|
|
url = "github:hyprwm/xdg-desktop-portal-hyprland";
|
|
|
|
};
|
2022-03-23 13:10:18 +01:00
|
|
|
|
2022-03-06 14:42:26 +01:00
|
|
|
qmk-udev-rules = {
|
|
|
|
url = "github:qmk/qmk_firmware";
|
|
|
|
flake = false;
|
|
|
|
};
|
2022-12-01 15:33:12 +01:00
|
|
|
jovian-nixos = {
|
|
|
|
url = "github:Jovian-Experiments/Jovian-NixOS";
|
|
|
|
flake = false;
|
|
|
|
};
|
2021-07-21 09:10:17 +02:00
|
|
|
};
|
2021-05-19 23:08:18 +02:00
|
|
|
|
2022-05-08 21:42:05 +02:00
|
|
|
nixConfig = {
|
2023-04-19 01:01:07 +02:00
|
|
|
# Only usefull if you're part of my VPN
|
2022-06-18 15:02:00 +02:00
|
|
|
extra-substituters = ["http://cache.home"];
|
2022-05-08 21:42:05 +02:00
|
|
|
};
|
|
|
|
|
2023-04-19 01:01:07 +02:00
|
|
|
outputs = inputs @ {flake-parts, ...}: let
|
|
|
|
# Overlays useful to most of my systems
|
|
|
|
overlaysSharedByAll = [
|
|
|
|
inputs.xdg-desktop-portal-hyprland.overlays.default
|
2023-07-12 21:11:25 +02:00
|
|
|
inputs.hyprland-contrib.overlays.default
|
2023-04-19 02:10:55 +02:00
|
|
|
(_: super: {
|
2023-04-19 01:01:07 +02:00
|
|
|
# Add my mensa tool
|
|
|
|
inherit (inputs.mensa.packages.x86_64-linux) mensa;
|
|
|
|
# TODO: Replace with upstream
|
|
|
|
inherit (inputs.fend.packages.x86_64-linux) fend;
|
|
|
|
hydra = inputs.hydra.packages.x86_64-linux.default;
|
|
|
|
# TODO: Remove once hydra fixes these removed aliases
|
|
|
|
inherit (super.perlPackages) buildPerlPackage;
|
|
|
|
netcat-openbsd = super.libressl.nc;
|
|
|
|
})
|
|
|
|
(import ./overlays/qmk-udev-rules.nix)
|
2022-03-23 13:10:18 +01:00
|
|
|
];
|
2023-04-19 01:01:07 +02:00
|
|
|
# Modules useful to most of my systems
|
|
|
|
modulesSharedByAllSystems = [
|
2022-03-23 13:10:18 +01:00
|
|
|
inputs.sops-nix.nixosModules.sops
|
2023-04-19 01:01:07 +02:00
|
|
|
inputs.self.nixosModules.nixUnstable
|
|
|
|
inputs.home-manager.nixosModules.home-manager
|
2022-03-23 13:10:18 +01:00
|
|
|
./modules/base-system.nix
|
|
|
|
];
|
2023-04-19 01:01:07 +02:00
|
|
|
# The list of all hosts known to me
|
|
|
|
listOfHosts = let
|
|
|
|
removeSuffix = builtins.replaceStrings [".nix"] [""];
|
|
|
|
hostDir = builtins.readDir ./hosts;
|
|
|
|
hostFileNames = builtins.attrNames hostDir;
|
|
|
|
in
|
|
|
|
map removeSuffix hostFileNames;
|
2022-03-23 13:10:18 +01:00
|
|
|
in
|
2023-04-19 01:01:07 +02:00
|
|
|
flake-parts.lib.mkFlake {inherit inputs;} {
|
|
|
|
# Flake-parts modules to use
|
|
|
|
imports = [
|
|
|
|
inputs.devshell.flakeModule
|
|
|
|
inputs.treefmt-nix.flakeModule
|
2023-04-19 02:10:55 +02:00
|
|
|
inputs.pre-commit-hooks-nix.flakeModule
|
2022-03-23 13:10:18 +01:00
|
|
|
];
|
2023-04-19 01:01:07 +02:00
|
|
|
# Available systems, only x86 for now
|
|
|
|
systems = ["x86_64-linux"];
|
|
|
|
perSystem = {
|
|
|
|
pkgs,
|
2023-04-19 02:10:55 +02:00
|
|
|
self',
|
2023-11-12 22:31:12 +01:00
|
|
|
config,
|
2023-04-19 01:01:07 +02:00
|
|
|
...
|
|
|
|
}: {
|
|
|
|
# Configure treefmt
|
|
|
|
treefmt.projectRootFile = "flake.nix";
|
|
|
|
treefmt.programs = {
|
|
|
|
alejandra.enable = true;
|
|
|
|
shellcheck.enable = true;
|
|
|
|
shfmt.enable = true;
|
2023-01-15 16:52:17 +01:00
|
|
|
};
|
2023-04-19 02:10:55 +02:00
|
|
|
# Configure pre-commit checks
|
|
|
|
pre-commit.settings.hooks.deadnix.enable = true;
|
|
|
|
pre-commit.settings.hooks.treefmt.enable = true;
|
|
|
|
pre-commit.settings.hooks.shellcheck.enable = true;
|
|
|
|
pre-commit.settings.hooks.markdownlint.enable = true;
|
2023-04-19 01:01:07 +02:00
|
|
|
# Load all packages from ./pkgs
|
|
|
|
packages = let
|
|
|
|
pkgFiles = builtins.attrNames (builtins.readDir ./pkgs);
|
|
|
|
toPackage = file: {
|
|
|
|
name = builtins.replaceStrings [".nix"] [""] file;
|
2023-09-10 00:34:14 +02:00
|
|
|
value = pkgs.callPackage ./pkgs/${file} {inherit inputs;};
|
2023-04-19 01:01:07 +02:00
|
|
|
};
|
|
|
|
in
|
|
|
|
builtins.listToAttrs (builtins.map toPackage pkgFiles);
|
|
|
|
# Create a useable devshell for me
|
2023-11-12 22:31:12 +01:00
|
|
|
devShells.default = pkgs.mkShell {
|
2023-04-19 01:01:07 +02:00
|
|
|
name = "dev";
|
2023-11-12 22:31:12 +01:00
|
|
|
shellHook = ''
|
|
|
|
${config.pre-commit.installationScript}
|
|
|
|
echo 1>&2 "Welcome to the development shell!"
|
|
|
|
'';
|
2023-04-19 01:01:07 +02:00
|
|
|
packages = [
|
|
|
|
pkgs.nil
|
2023-04-19 02:10:55 +02:00
|
|
|
pkgs.pre-commit
|
2023-04-19 01:01:07 +02:00
|
|
|
self'.packages.rebuild
|
|
|
|
self'.packages.personal-cache
|
|
|
|
self'.packages.all-hosts
|
|
|
|
self'.packages.option
|
|
|
|
self'.packages.test-config
|
2022-12-01 15:33:12 +01:00
|
|
|
];
|
|
|
|
};
|
2021-12-26 20:44:36 +01:00
|
|
|
};
|
2023-04-19 01:01:07 +02:00
|
|
|
# Useful modules and all those from ./modules
|
|
|
|
flake.nixosModules =
|
2022-03-23 13:10:18 +01:00
|
|
|
{
|
2023-04-19 01:01:07 +02:00
|
|
|
homeManagerConfig = _: {
|
|
|
|
home-manager.verbose = true;
|
|
|
|
home-manager.useGlobalPkgs = true;
|
|
|
|
home-manager.useUserPackages = true;
|
|
|
|
home-manager.extraSpecialArgs = {inherit (inputs) nix-colors;};
|
|
|
|
};
|
|
|
|
nixUnstable = {pkgs, ...}: {
|
|
|
|
nix.registry.nixpkgs.flake = inputs.nixpkgs;
|
|
|
|
nix.package = pkgs.nixUnstable;
|
|
|
|
nix.extraOptions = ''
|
|
|
|
experimental-features = nix-command flakes
|
|
|
|
'';
|
|
|
|
};
|
2022-03-23 13:10:18 +01:00
|
|
|
}
|
2023-04-19 01:01:07 +02:00
|
|
|
// (let
|
|
|
|
removeSuffix = builtins.replaceStrings [".nix"] [""];
|
|
|
|
moduleFiles = builtins.attrNames (builtins.readDir ./modules);
|
|
|
|
listOfModules = builtins.map removeSuffix moduleFiles;
|
|
|
|
toModule = name: {
|
|
|
|
inherit name;
|
|
|
|
value = builtins.readFile ./modules/${name};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
builtins.listToAttrs (builtins.map toModule listOfModules));
|
|
|
|
# All my system's configurations
|
|
|
|
flake.nixosConfigurations = let
|
|
|
|
genSystem = name: {
|
|
|
|
inherit name;
|
|
|
|
value = inputs.nixpkgs.lib.nixosSystem {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
specialArgs = {inherit inputs;};
|
|
|
|
modules = modulesSharedByAllSystems ++ [{nixpkgs.overlays = overlaysSharedByAll;} ./hosts/${name}.nix];
|
|
|
|
};
|
2022-03-23 13:10:18 +01:00
|
|
|
};
|
2023-04-19 01:01:07 +02:00
|
|
|
in
|
|
|
|
builtins.listToAttrs (builtins.map genSystem listOfHosts);
|
|
|
|
# Iso for USB
|
|
|
|
flake.packages.x86_64-linux.iso = inputs.self.nixosConfigurations.radix-balthica.config.system.build.isoImage;
|
|
|
|
# VM for testing
|
|
|
|
flake.packages.x86_64-linux.vm = inputs.self.nixosConfigurations.radix-balthica.config.system.build.vm;
|
|
|
|
# Copy most things to hydraJobs so hydra evaluates and builds them
|
|
|
|
flake.hydraJobs = {
|
|
|
|
inherit (inputs.self) packages devShells;
|
|
|
|
nixosConfigurations.x86_64-linux = builtins.listToAttrs (builtins.map (name: {
|
|
|
|
inherit name;
|
|
|
|
value = inputs.self.nixosConfigurations.${name}.config.system.build.toplevel;
|
|
|
|
})
|
|
|
|
listOfHosts);
|
2021-12-22 21:37:23 +01:00
|
|
|
};
|
2022-03-23 13:10:18 +01:00
|
|
|
};
|
2021-05-19 23:08:18 +02:00
|
|
|
}
|