7 Commits

Author SHA1 Message Date
f23fbd001e -repl-flakes, fix:homeConfiguration module 2024-11-25 09:52:33 +01:00
d22b436fb1 video 17 2024-11-02 18:03:16 +01:00
d0b1d9b775 video 16 2024-10-24 13:29:49 +02:00
c6d1b9a2ad video15 2024-10-17 18:57:52 +02:00
6c720bdac6 video13 2024-10-10 14:52:28 +02:00
6139657197 video12 2024-10-05 06:46:12 +02:00
e7ec54ef4f video10 2024-09-26 14:45:59 +02:00
24 changed files with 528 additions and 43 deletions

150
flake.lock generated
View File

@ -21,6 +21,27 @@
"type": "github"
}
},
"colmena": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2",
"stable": "stable"
},
"locked": {
"lastModified": 1728263678,
"narHash": "sha256-gyUVsPAWY9AgVKjrNPoowrIr5BvK4gI0UkDXvv8iSxA=",
"owner": "zhaofengli",
"repo": "colmena",
"rev": "b0a62f234fae02a006123e661ff70e62af16106b",
"type": "github"
},
"original": {
"owner": "zhaofengli",
"repo": "colmena",
"type": "github"
}
},
"darwin": {
"inputs": {
"nixpkgs": [
@ -50,11 +71,11 @@
]
},
"locked": {
"lastModified": 1726524467,
"narHash": "sha256-xkPPPvfHhHK7BNX5ZrQ9N6AIEixCmFzRZHduDf0zv30=",
"lastModified": 1728922573,
"narHash": "sha256-FegyBabjV4868aJUbvFtqH0zKDEtUpeCAfnB1vWXeBg=",
"owner": "nix-community",
"repo": "disko",
"rev": "22ee467a54a3ab7fa9d637ccad5330c6c087e9dc",
"rev": "3b778f10eb275573da9f5c8a7a49e774200b87e5",
"type": "github"
},
"original": {
@ -66,11 +87,11 @@
"dotfiles": {
"flake": false,
"locked": {
"lastModified": 1725956275,
"narHash": "sha256-4tHKP+PLpJKnFfOT6MY3p/NDBr/3NDyWljB8/iELVZs=",
"lastModified": 1726139078,
"narHash": "sha256-FiyYP/hTiSOkj99P1YcIxc9uJjjInpMPAp6fKtZlkNs=",
"ref": "refs/heads/master",
"rev": "b1393f4b54b8e908b770450ccc49400713d8e457",
"revCount": 1,
"rev": "d9f3a3ba9d8430306a4f6f7e9fd3ad618d274c8e",
"revCount": 2,
"type": "git",
"url": "https://code.m3tam3re.com/m3tam3re/dotfiles-flake-demo.git"
},
@ -79,6 +100,37 @@
"url": "https://code.m3tam3re.com/m3tam3re/dotfiles-flake-demo.git"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -107,11 +159,11 @@
]
},
"locked": {
"lastModified": 1712016346,
"narHash": "sha256-O2nO7pD+krq+4HgkLB4VThRtAucIPfXDs/jJqCGlK1w=",
"lastModified": 1726817922,
"narHash": "sha256-gO91NgBTTbVHBlvnn6g6XFeXzJquBH5MrVhYMFTnB0Q=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "4be0464472675212654dedf3e021bd5f1d58b92f",
"rev": "f48b181f0161db6246a1bd1b05d70a7b3a87ab41",
"type": "github"
},
"original": {
@ -120,6 +172,23 @@
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1730184279,
"narHash": "sha256-6OB+WWR6gnaWiqSS28aMJypKeK7Pjc2Wm6L0MtOrTuA=",
"owner": "LnL7",
"repo": "nix-darwin",
"rev": "b379bd4d872d159e5189053ce9a4adf86d56db4b",
"type": "github"
},
"original": {
"id": "nix-darwin",
"type": "indirect"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1703013332,
@ -138,11 +207,11 @@
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1724531977,
"narHash": "sha256-XROVLf9ti4rrNCFLr+DmXRZtPjCQTW4cYy59owTEmxk=",
"lastModified": 1726447378,
"narHash": "sha256-2yV8nmYE1p9lfmLHhOCbYwQC/W8WYfGQABoGzJOb1JQ=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "2527da1ef492c495d5391f3bcf9c1dd9f4514e32",
"rev": "086b448a5d54fd117f4dc2dee55c9f0ff461bdc1",
"type": "github"
},
"original": {
@ -154,11 +223,40 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1711703276,
"narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=",
"lastModified": 1725103162,
"narHash": "sha256-Ym04C5+qovuQDYL/rKWSR+WESseQBbNAe5DsXNx5trY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "12228ff1752d7b7624a54e9c1af4b222b3c1073b",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1729665710,
"narHash": "sha256-AlcmCXJZPIlO5dmFzV3V2XF6x/OpNWUV8Y/FMPGd8Z4=",
"path": "/nix/store/lsy6c2f9alj2gkjj36h754kk63x6701l-source",
"rev": "2768c7d042a37de65bb1b5b3268fc987e534c49d",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1726463316,
"narHash": "sha256-gI9kkaH0ZjakJOKrdjaI/VbaMEo9qBbSUl93DnU7f4c=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d8fe5e6c92d0d190646fb9f1056741a229980089",
"rev": "99dc8785f6a0adac95f5e2ab05cc2e1bf666d172",
"type": "github"
},
"original": {
@ -171,13 +269,31 @@
"root": {
"inputs": {
"agenix": "agenix",
"colmena": "colmena",
"disko": "disko",
"dotfiles": "dotfiles",
"home-manager": "home-manager_2",
"nixpkgs": "nixpkgs_2",
"nix-darwin": "nix-darwin",
"nixpkgs": "nixpkgs_4",
"nixpkgs-stable": "nixpkgs-stable"
}
},
"stable": {
"locked": {
"lastModified": 1724316499,
"narHash": "sha256-Qb9MhKBUTCfWg/wqqaxt89Xfi6qTD3XpTzQ9eXi3JmE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "797f7dc49e0bc7fab4b57c021cdf68f595e47841",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,

View File

@ -18,6 +18,8 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.05";
colmena.url = "github:zhaofengli/colmena";
agenix.url = "github:ryantm/agenix";
disko = {
@ -34,10 +36,10 @@
outputs = {
self,
agenix,
disko,
dotfiles,
home-manager,
nix-darwin,
nixpkgs,
nixpkgs-stable,
...
} @ inputs: let
inherit (self) outputs;
@ -53,6 +55,7 @@
packages =
forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system});
overlays = import ./overlays {inherit inputs;};
homeManagerModules = import ./modules/home-manager;
nixosConfigurations = {
m3-kratos-vm = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs outputs;};
@ -70,5 +73,25 @@
modules = [./home/m3tam3re/m3-kratos.nix];
};
};
colmena = {
meta = {
nixpkgs = import nixpkgs {
system = "x86_64-linux";
};
specialArgs = {inherit inputs outputs;};
};
m3-kratos-vm = {
deployment = {
targetHost = "m3-kratos-vm";
targetUser = "m3tam3re";
tags = ["vm"];
};
imports = [
./hosts/m3-kratos
inputs.disko.nixosModules.disko
agenix.nixosModules.default
];
};
};
};
}

View File

@ -5,6 +5,7 @@
pkgs,
...
}: {
imports = builtins.attrValues outputs.homeManagerModules;
nixpkgs = {
# You can add overlays here
overlays = [

View File

@ -22,6 +22,7 @@
home.packages = with pkgs; [
coreutils
fd
gcc
htop
httpie
jq

View File

@ -30,7 +30,7 @@ in {
];
input = {
kb_layout = "de,us";
kb_layout = "us";
kb_variant = "";
kb_model = "";
kb_rules = "";

View File

@ -26,6 +26,8 @@
home.packages = with pkgs; [
kitty
wofi
firefox
n8n
# # Adds the 'hello' command to your environment. It prints a friendly
# # "Hello, world!" when run.
# pkgs.hello
@ -80,4 +82,26 @@
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
programs.zellij-ps = {
enable = true;
projectFolders = [
"${config.home.homeDirectory}/.config"
];
layout = ''
layout {
pane size=1 borderless=true {
plugin location="zellij:tab-bar"
}
pane size="70%" command="nvim"
pane split_direction="vertical" {
pane
pane command="unimatrix"
}
pane size=1 borderless=true {
plugin location="zellij:status-bar"
}
}
'';
};
}

View File

@ -40,7 +40,9 @@
};
};
nix = {
nix = let
flakeInputs = lib.filterAttrs (_: lib.isType "flake") inputs;
in {
settings = {
experimental-features = "nix-command flakes";
trusted-users = [
@ -53,10 +55,8 @@
options = "--delete-older-than 30d";
};
optimise.automatic = true;
registry =
(lib.mapAttrs (_: flake: {inherit flake;}))
((lib.filterAttrs (_: lib.isType "flake")) inputs);
nixPath = ["/etc/nix/path"];
registry = lib.mapAttrs (_: flake: {inherit flake;}) flakeInputs;
nixPath = ["/etc/nix/path"] ++ lib.mapAttrsToList (flakeName: _: "${flakeName}=flake:${flakeName}") flakeInputs;
};
users.defaultUserShell = pkgs.fish;
}

View File

@ -21,7 +21,7 @@
# Enable networking
networking.networkmanager.enable = true;
networking.networkmanager.unmanaged = ["interface-name:ve-*"];
# Set your time zone.
time.timeZone = "Europe/Berlin";
@ -86,13 +86,20 @@
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
networking.nat.enable = true;
networking.nat.internalInterfaces = ["ve-+"];
networking.nat.externalInterface = "enp1s0";
#security.sudo.wheelNeedsPassword = false;
security.sudo.extraConfig = "m3tam3re ALL=(ALL) NOPASSWD: ALL";
# networking.firewall.enable = false;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "24.05"; # Did you read the comment?
system.stateVersion = "24.11"; # Did you read the comment?
}

View File

@ -38,7 +38,7 @@
./configuration.nix
./secrets.nix
./services
./specialisations.nix
];
extraServices.podman.enable = true;
}

View File

@ -1,6 +1,7 @@
{
imports = [
./echo.nix
./httpd.nix
./nginx.nix
];
}

View File

@ -2,7 +2,7 @@
virtualisation.oci-containers.containers."echo-http-service" = {
image = "hashicorp/http-echo";
extraOptions = ["-text='Hello, World!'" "--network=web"];
ports = ["5678:5678"];
ports = ["5679:5678"];
};
system.activationScripts.createPodmanNetworkWeb = lib.mkAfter ''
if ! /run/current-system/sw/bin/podman network exists web; then

View File

@ -0,0 +1,56 @@
{
containers.httpd = {
autoStart = true;
ephemeral = true;
privateNetwork = true;
hostAddress = "192.168.100.10";
localAddress = "192.168.100.11";
forwardPorts = [
{
containerPort = 80;
hostPort = 80;
}
];
config = {...}: {
services.httpd = {
enable = true;
adminAddr = "foo@example.org";
};
networking.firewall.allowedTCPPorts = [80];
system.stateVersion = "24.05";
};
bindMounts = {
"/root/data" = {
hostPath = "/home/m3tam3re/data/";
isReadOnly = false;
};
};
};
containers.httpd2 = {
autoStart = true;
ephemeral = true;
privateNetwork = true;
hostAddress = "192.168.100.10";
localAddress = "192.168.100.12";
forwardPorts = [
{
containerPort = 80;
hostPort = 8080;
}
];
config = {...}: {
services.httpd = {
enable = true;
adminAddr = "foo@example.org";
};
networking.firewall.allowedTCPPorts = [80];
system.stateVersion = "24.05";
};
bindMounts = {
"/root/data" = {
hostPath = "/home/m3tam3re/data/";
isReadOnly = false;
};
};
};
}

View File

@ -1,5 +1,6 @@
{
imports = [
./containers
./n8n.nix
];
}

View File

@ -0,0 +1,11 @@
{
services.n8n = {
enable = true;
openFirewall = true;
};
systemd.services.n8n = {
environment = {
N8N_SECURE_COOKIE = "false";
};
};
}

View File

@ -0,0 +1,83 @@
{
config,
lib,
pkgs,
...
}: {
specialisation = {
"HTTPD".configuration = {
system.nixos.tags = ["HTTPD"];
services.httpd.enable = true;
services.httpd.virtualHosts."foo.example.com" = {
documentRoot = "/var/www/foo";
extraConfig = ''
<Directory /var/www/foo>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
'';
};
};
"NGINX".configuration = {
system.nixos.tags = ["NGINX"];
services.httpd.enable = false;
services.nginx.enable = true;
services.nginx.config = ''
http {
server {
listen 80;
server_name bar.example.com;
root /var/www/bar;
location / {
index index.html;
}
}
}
'';
};
"NVIDIA".configuration = {
boot.kernelParams = [
"nvidia.NVreg_PreserveVideoMemoryAllocations=1"
"nvidia-drm.modeset=1"
];
system.nixos.tags = ["NVIDIA"];
services.xserver.videoDrivers = ["nvidia"];
hardware = {
nvidia = {
open = false;
package = config.boot.kernelPackages.nvidiaPackages.stable;
modesetting.enable = true;
powerManagement.enable = true;
};
graphics = {
enable = true;
enable32Bit = true;
};
};
environment.sessionVariables = {
GBM_BACKEND = "nvidia-drm";
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
LIBVA_DRIVER_NAME = "nvidia";
QT_QPA_PLATFORM = "wayland";
WLR_NO_HARDWARE_CURSORS = "1";
XDG_SESSION_TYPE = "wayland";
};
};
};
environment.systemPackages = [
(pkgs.writeShellScriptBin "switch-spec" ''
if [ $# -ne 1 ]; then
echo "Usage: switch-spec <specialisation>"
exit 1
fi
sudo /nix/var/nix/profiles/system/specialisation/$1/bin/switch-to-configuration switch
'')
];
environment.sessionVariables = lib.mkIf (config.specialisation != {}) {
SPECIALISATION = "NONE";
};
}

42
justfile Normal file
View File

@ -0,0 +1,42 @@
# List available commands
default:
@just --list
# Deploy system configuration
deploy SYSTEM:
nixos-rebuild switch --flake .#{{SYSTEM}} --target-host {{SYSTEM}} --use-remote-sudo
# Update flake
update:
nix flake update
# Commit and push changes
commit MESSAGE:
git add .
git commit -m "{{MESSAGE}}"
git push
# Update, commit, and push changes
update-and-commit MESSAGE: update
@just commit "{{MESSAGE}}"
# Deploy, update, commit, and push changes
deploy-update-commit SYSTEM MESSAGE: (deploy SYSTEM) update
@just commit "{{MESSAGE}}"
# Check flake
check:
nix flake check
# Show flake info
show:
nix flake show
# Build system configuration
build SYSTEM:
nixos-rebuild build --flake .#{{SYSTEM}}
# Enter a development shell
dev-shell:
nix develop

View File

@ -0,0 +1,3 @@
{
zellij-ps = import ./zellij-ps.nix;
}

View File

@ -0,0 +1,44 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.programs.zellij-ps;
in {
options = {
programs.zellij-ps = {
enable = mkEnableOption "Zellij Project Selector";
projectFolders = lib.mkOption {
type = lib.types.listOf lib.types.path;
description = "List of project folders for zellij-ps.";
default = ["${config.home.homeDirectory}/projects"];
};
layout = lib.mkOption {
type = lib.types.str;
description = "Layout for zellij";
default = ''
layout {
pane size=1 borderless=true {
plugin location="zellij:tab-bar"
}
pane
pane split_direction="vertical" {
pane
pane command="htop"
}
pane size=2 borderless=true {
plugin location="zellij:status-bar"
}
}
'';
};
};
};
config = mkIf cfg.enable {
home.packages = [pkgs.zellij-ps];
home.sessionVariables.PROJECT_FOLDERS = lib.concatStringsSep ":" cfg.projectFolders;
home.file.".config/zellij/layouts/zellij-ps.kdl".text = cfg.layout;
};
}

View File

@ -5,11 +5,8 @@
# This one contains whatever you want to overlay
# You can change versions, add patches, set compilation flags, anything really.
# https://nixos.wiki/wiki/Overlays
modifications = final: prev:
{
# example = prev.example.overrideAttrs (oldAttrs: rec {
# ...
# });
modifications = final: prev: {
n8n = import ./mods/n8n.nix {inherit prev;};
};
stable-packages = final: _prev: {

17
overlays/mods/n8n.nix Normal file
View File

@ -0,0 +1,17 @@
{prev}:
prev.n8n.overrideAttrs (oldAttrs: rec {
pname = oldAttrs.pname;
version = "1.63.0";
src = prev.fetchFromGitHub {
owner = "n8n-io";
repo = "n8n";
rev = "n8n@${version}";
hash = "sha256-zJHveCbBPJs8qbgCsU+dgucoXpAKa7PVLH4tfdcJZlE=";
};
pnpmDeps = prev.pnpm.fetchDeps {
inherit pname version src;
hash = "sha256-FsBA/QENfreCJnYCw8MnX5W2D+WJ3DUuTIakH78TYU8=";
};
})

View File

@ -1,5 +1,5 @@
{ pkgs, ... }:
{
{pkgs, ...}: {
# Define your custom packages here
# my-package = pkgs.callPackage ./my-package {};
zellij-ps = pkgs.callPackage ./zellij-ps {};
n8n-custom = pkgs.callPackage ./n8n-custom {};
}

View File

@ -1,2 +0,0 @@
# Your custom nix-package
# ...

View File

@ -0,0 +1,21 @@
{
fetchFromGitHub,
n8n,
pnpm,
}:
n8n.overrideAttrs (oldAttrs: rec {
pname = oldAttrs.pname;
version = "1.63.0";
src = fetchFromGitHub {
owner = "n8n-io";
repo = "n8n";
rev = "n8n@${version}";
hash = "sha256-zJHveCbBPJs8qbgCsU+dgucoXpAKa7PVLH4tfdcJZlE=";
};
pnpmDeps = pnpm.fetchDeps {
inherit pname version src;
hash = "sha256-FsBA/QENfreCJnYCw8MnX5W2D+WJ3DUuTIakH78TYU8=";
};
})

View File

@ -0,0 +1,39 @@
{
lib,
fish,
fd,
fzf,
makeWrapper,
zellij,
fetchFromGitea,
stdenv,
}:
stdenv.mkDerivation {
pname = "zellij-ps";
version = "0.1.0";
src = fetchFromGitea {
domain = "code.m3tam3re.com";
owner = "m3tam3re";
repo = "helper-scripts";
rev = "08a3217b83391c1110545c1ee3161eecd5dbe5e9";
sha256 = "1sc4i58mwcg3qsq0wwl5rvk08ykbxc497bq7mrxiirndsarskby7";
};
buildInputs = [];
nativeBuildInputs = [makeWrapper];
installPhase = ''
mkdir -p $out/bin
cp zellij-ps.fish $out/bin/zellij-ps
wrapProgram $out/bin/zellij-ps \
--prefix PATH : ${lib.makeBinPath [fish fd fzf zellij]}
'';
meta = with lib; {
description = "A small project script for zellij";
homepage = "https://code.m3tam3re.com/m3tam3re/helper-scripts";
license = licenses.mit;
maintainers = with maintainers; [m3tam3re];
platforms = platforms.unix;
};
}