Massive nixfmt reformatting

This commit is contained in:
Natsu Kagami 2025-04-03 13:59:50 +02:00
parent fe4492f004
commit b29ddd5e65
Signed by: nki
GPG key ID: 55A032EB38B49ADB
109 changed files with 4323 additions and 2368 deletions

View file

@ -1,4 +1,3 @@
# WARN: this file will get overwritten by $ cachix use <name> # WARN: this file will get overwritten by $ cachix use <name>
{ pkgs, lib, ... }: { pkgs, lib, ... }:
@ -7,7 +6,8 @@ let
toImport = name: value: folder + ("/" + name); toImport = name: value: folder + ("/" + name);
filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key; filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key;
imports = lib.mapAttrsToList toImport (lib.filterAttrs filterCaches (builtins.readDir folder)); imports = lib.mapAttrsToList toImport (lib.filterAttrs filterCaches (builtins.readDir folder));
in { in
{
inherit imports; inherit imports;
nix.settings.substituters = [ "https://cache.nixos.org/" ]; nix.settings.substituters = [ "https://cache.nixos.org/" ];
} }

View file

@ -1,4 +1,3 @@
{ {
nix = { nix = {
settings = { settings = {

View file

@ -1,7 +1,18 @@
let let
# Default shell # Default shell
defaultShell = { lib, pkgs, config, ... }: with lib; { defaultShell =
environment.shells = with pkgs; [ bash fish ]; {
lib,
pkgs,
config,
...
}:
with lib;
{
environment.shells = with pkgs; [
bash
fish
];
users.users = mkMerge [ users.users = mkMerge [
{ nki.shell = pkgs.bash; } { nki.shell = pkgs.bash; }
# (mkIf (builtins.hasAttr "natsukagami" config.users.users) { natsukagami.shell = pkgs.fish; }) # (mkIf (builtins.hasAttr "natsukagami" config.users.users) { natsukagami.shell = pkgs.fish; })
@ -9,8 +20,14 @@ let
}; };
in in
# Common stuff # Common stuff
{ lib, pkgs, config, ... }: {
with lib; { lib,
pkgs,
config,
...
}:
with lib;
{
imports = [ imports = [
# defaultShell # defaultShell
./modules/services/nix-cache ./modules/services/nix-cache

View file

@ -1,11 +1,14 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
{ {
homebrew.enable = true; homebrew.enable = true;
homebrew.brewPrefix = homebrew.brewPrefix = if pkgs.stdenv.isAarch64 then "/opt/homebrew/bin" else "/usr/local/bin";
if pkgs.stdenv.isAarch64 then "/opt/homebrew/bin"
else "/usr/local/bin";
homebrew.onActivation.cleanup = "zap"; homebrew.onActivation.cleanup = "zap";
homebrew.onActivation.upgrade = true; homebrew.onActivation.upgrade = true;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
{ {
imports = [ imports = [
@ -7,8 +12,10 @@
]; ];
# List packages installed in system profile. To search by name, run: # List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget # $ nix-env -qaP | grep wget
environment.systemPackages = environment.systemPackages = with pkgs; [
with pkgs; [ podman qemu ]; podman
qemu
];
environment.shells = with pkgs; [ fish ]; environment.shells = with pkgs; [ fish ];

View file

@ -61,16 +61,31 @@
secrets.url = "git+ssh://git@github.com/natsukagami/nix-deploy-secrets"; secrets.url = "git+ssh://git@github.com/natsukagami/nix-deploy-secrets";
}; };
outputs = { self, darwin, nixpkgs, nixpkgs-unstable, home-manager, deploy-rs, sops-nix, ... }@inputs: outputs =
{
self,
darwin,
nixpkgs,
nixpkgs-unstable,
home-manager,
deploy-rs,
sops-nix,
...
}@inputs:
let let
overlays = import ./overlay.nix inputs; overlays = import ./overlay.nix inputs;
lib = nixpkgs.lib; lib = nixpkgs.lib;
applyOverlays = { ... }: { applyOverlays =
{ ... }:
{
nixpkgs.overlays = lib.mkAfter overlays; nixpkgs.overlays = lib.mkAfter overlays;
}; };
nixpkgsAsRegistry_ = stable: { lib, ... }: { nixpkgsAsRegistry_ =
stable:
{ lib, ... }:
{
imports = [ applyOverlays ]; imports = [ applyOverlays ];
nix.registry.current-system.flake = self; nix.registry.current-system.flake = self;
nix.registry.nixpkgs-unstable.flake = nixpkgs-unstable; nix.registry.nixpkgs-unstable.flake = nixpkgs-unstable;
@ -80,7 +95,9 @@
]; ];
}; };
osuStable = { pkgs, ... }: { osuStable =
{ pkgs, ... }:
{
nix.settings = { nix.settings = {
substituters = [ "https://nix-gaming.cachix.org" ]; substituters = [ "https://nix-gaming.cachix.org" ];
trusted-public-keys = [ "nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4=" ]; trusted-public-keys = [ "nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4=" ];
@ -103,7 +120,10 @@
}; };
# Common Nix modules # Common Nix modules
common-nix = stable: { ... }: { common-nix =
stable:
{ ... }:
{
imports = [ imports = [
(nixpkgsAsRegistry_ stable) (nixpkgsAsRegistry_ stable)
./common.nix ./common.nix
@ -112,7 +132,10 @@
]; ];
config.nix.settings.extra-deprecated-features = [ "url-literals" ]; # So lix won't complain config.nix.settings.extra-deprecated-features = [ "url-literals" ]; # So lix won't complain
}; };
common-nixos = stable: { ... }: { common-nixos =
stable:
{ ... }:
{
imports = [ imports = [
./modules/my-tinc ./modules/my-tinc
./modules/common/linux ./modules/common/linux
@ -123,24 +146,35 @@
]; ];
}; };
mkPersonalSystem = nixpkgs-module: system: { configuration mkPersonalSystem =
, homeManagerUsers ? { } nixpkgs-module: system:
, extraModules ? [ ] {
, includeCommonModules ? true configuration,
, homeManagerUsers ? { },
extraModules ? [ ],
includeCommonModules ? true,
}: }:
let let
home-manager-module = home-manager-module =
if nixpkgs-module == inputs.nixpkgs then inputs.home-manager if nixpkgs-module == inputs.nixpkgs then
else if nixpkgs-module == inputs.nixpkgs-unstable then inputs.home-manager-unstable inputs.home-manager
else builtins.abort "Unknown nixpkgs module, use `nixpkgs` or `nixpkgs-unstable`"; else if nixpkgs-module == inputs.nixpkgs-unstable then
inputs.home-manager-unstable
else
builtins.abort "Unknown nixpkgs module, use `nixpkgs` or `nixpkgs-unstable`";
in in
nixpkgs-module.lib.nixosSystem { nixpkgs-module.lib.nixosSystem {
inherit system; inherit system;
modules = modules =
(if includeCommonModules then [ (
if includeCommonModules then
[
(common-nixos nixpkgs-module) (common-nixos nixpkgs-module)
] else [ ]) ++ [ ]
else
[ ]
)
++ [
configuration configuration
# Home Manager # Home Manager
home-manager-module.nixosModules.home-manager home-manager-module.nixosModules.home-manager
@ -149,7 +183,8 @@
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.users = homeManagerUsers; home-manager.users = homeManagerUsers;
} }
] ++ extraModules; ]
++ extraModules;
}; };
in in
@ -186,14 +221,17 @@
homeManagerUsers.nki = import ./home/nki-x1c1.nix; homeManagerUsers.nki = import ./home/nki-x1c1.nix;
extraModules = [ extraModules = [
inputs.lanzaboote.nixosModules.lanzaboote inputs.lanzaboote.nixosModules.lanzaboote
({ ... }: { (
{ ... }:
{
# Sets up secure boot # Sets up secure boot
boot.loader.systemd-boot.enable = lib.mkForce false; boot.loader.systemd-boot.enable = lib.mkForce false;
boot.lanzaboote = { boot.lanzaboote = {
enable = true; enable = true;
pkiBundle = "/etc/secureboot"; pkiBundle = "/etc/secureboot";
}; };
}) }
)
]; ];
}; };
# framework configuration # framework configuration
@ -203,14 +241,17 @@
extraModules = [ extraModules = [
inputs.lanzaboote.nixosModules.lanzaboote inputs.lanzaboote.nixosModules.lanzaboote
inputs.nixos-hardware.nixosModules.framework-13-7040-amd inputs.nixos-hardware.nixosModules.framework-13-7040-amd
({ ... }: { (
{ ... }:
{
# Sets up secure boot # Sets up secure boot
boot.loader.systemd-boot.enable = lib.mkForce false; boot.loader.systemd-boot.enable = lib.mkForce false;
boot.lanzaboote = { boot.lanzaboote = {
enable = true; enable = true;
pkiBundle = "/etc/secureboot"; pkiBundle = "/etc/secureboot";
}; };
}) }
)
]; ];
}; };
# macbook nixos # macbook nixos

View file

@ -1,8 +1,18 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let
kwallet = { pkgs, lib, ... }: { kwallet =
home.packages = with pkgs; [ kdePackages.kwallet kdePackages.ksshaskpass ]; { pkgs, lib, ... }:
{
home.packages = with pkgs; [
kdePackages.kwallet
kdePackages.ksshaskpass
];
home.sessionVariables = { home.sessionVariables = {
# https://wiki.archlinux.org/title/KDE_Wallet#Using_the_KDE_Wallet_to_store_ssh_key_passphrases # https://wiki.archlinux.org/title/KDE_Wallet#Using_the_KDE_Wallet_to_store_ssh_key_passphrases
SSH_ASKPASS = lib.getExe pkgs.kdePackages.ksshaskpass; SSH_ASKPASS = lib.getExe pkgs.kdePackages.ksshaskpass;
@ -27,7 +37,8 @@ in
./modules/X11/xfce4-notifyd.nix ./modules/X11/xfce4-notifyd.nix
kwallet kwallet
]; ];
config = (mkIf pkgs.stdenv.isLinux { config = (
mkIf pkgs.stdenv.isLinux {
home.packages = with pkgs; [ home.packages = with pkgs; [
psmisc # killall and friends psmisc # killall and friends
file # Query file type file # Query file type
@ -54,6 +65,6 @@ in
# UDisks automounter # UDisks automounter
services.udiskie.enable = true; services.udiskie.enable = true;
});
} }
);
}

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
{ {
imports = [ imports = [
@ -52,7 +57,6 @@
$pdf_previewer = '${lib.getExe' pkgs.xdg-utils "xdg-open"}'; $pdf_previewer = '${lib.getExe' pkgs.xdg-utils "xdg-open"}';
''; '';
home.sessionVariables = { home.sessionVariables = {
# Bat theme # Bat theme
BAT_THEME = "GitHub"; BAT_THEME = "GitHub";

View file

@ -1,4 +1,10 @@
{ config, options, pkgs, lib, ... }: {
config,
options,
pkgs,
lib,
...
}:
with lib; with lib;
let let
@ -157,7 +163,6 @@ in
}; };
}; };
tide = { tide = {
enable = true; enable = true;
leftItems = options.programs.fish.tide.leftItems.default; leftItems = options.programs.fish.tide.leftItems.default;
@ -172,10 +177,7 @@ in
}; };
everywhereAbbrs = { everywhereAbbrs = {
lsports = lsports = if pkgs.stdenv.isDarwin then "lsof -i -P | grep LISTEN" else "ss -tulp";
if pkgs.stdenv.isDarwin
then "lsof -i -P | grep LISTEN"
else "ss -tulp";
}; };
shellInit = '' shellInit = ''
@ -234,11 +236,11 @@ in
bind -M default gl end-of-line bind -M default gl end-of-line
# Everywhere abbrs # Everywhere abbrs
${ ${concatStringsSep "\n" (
concatStringsSep "\n" mapAttrsToList (
(mapAttrsToList (k: v: "abbr --add --position anywhere -- ${k} ${escapeShellArg v}") k: v: "abbr --add --position anywhere -- ${k} ${escapeShellArg v}"
config.programs.fish.everywhereAbbrs) ) config.programs.fish.everywhereAbbrs
} )}
# Replace today with actual today # Replace today with actual today
abbr --add --position anywhere today -f echo-today abbr --add --position anywhere today -f echo-today

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
with lib; with lib;
let let
@ -42,16 +47,27 @@ in
leftItems = mkOption { leftItems = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
description = "The list of left-items. Note that `newline` and `character` is not included here and will always appear last"; description = "The list of left-items. Note that `newline` and `character` is not included here and will always appear last";
default = [ "os" "context" "pwd" "git" ]; default = [
"os"
"context"
"pwd"
"git"
];
}; };
}; };
config.programs.fish = config.programs.fish =
let let
tideItems = attrsets.mapAttrs' (name: def: { name = "_tide_item_${name}"; value = def; }); tideItems = attrsets.mapAttrs' (
name: def: {
name = "_tide_item_${name}";
value = def;
}
);
in in
mkIf cfg.enable { mkIf cfg.enable {
functions = tideItems ({ functions = tideItems (
{
nix_shell = '' nix_shell = ''
# In a Nix Shell # In a Nix Shell
if set -qx DIRENV_FILE && test -f $DIRENV_FILE && rg -q "^use flake" $DIRENV_FILE if set -qx DIRENV_FILE && test -f $DIRENV_FILE && rg -q "^use flake" $DIRENV_FILE
@ -60,7 +76,9 @@ in
_tide_print_item nix_shell "" _tide_print_item nix_shell ""
end end
''; '';
} // cfg.items); }
// cfg.items
);
plugins = [ plugins = [
{ {
name = "tide"; name = "tide";
@ -78,7 +96,9 @@ in
config.xdg.configFile."fish/tide/init.fish" = { config.xdg.configFile."fish/tide/init.fish" = {
text = '' text = ''
# Configure tide items # Configure tide items
set -U tide_left_prompt_items ${concatMapStringsSep " " escapeShellArg cfg.leftItems} newline character set -U tide_left_prompt_items ${
concatMapStringsSep " " escapeShellArg cfg.leftItems
} newline character
set -U tide_right_prompt_items ${concatMapStringsSep " " escapeShellArg cfg.rightItems} time set -U tide_right_prompt_items ${concatMapStringsSep " " escapeShellArg cfg.rightItems} time
''; '';

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
{ {
imports = [ imports = [
@ -14,7 +19,9 @@
home.homeDirectory = "/home/nki"; home.homeDirectory = "/home/nki";
# More packages # More packages
home.packages = (with pkgs; [ home.packages = (
with pkgs;
[
# Gaming stuff # Gaming stuff
wineWowPackages.full wineWowPackages.full
# wine-lol # wine-lol
@ -26,7 +33,8 @@
flacon flacon
ttaenc ttaenc
picard picard
]); ]
);
# Enable X11 configuration # Enable X11 configuration
linux.graphical.type = "wayland"; linux.graphical.type = "wayland";
@ -46,11 +54,23 @@
# 144hz adaptive refresh ON! # 144hz adaptive refresh ON!
nki.programs.kitty.enable = true; nki.programs.kitty.enable = true;
nki.programs.kitty.fontSize = 14; nki.programs.kitty.fontSize = 14;
programs.my-waybar.makeBars = with config.common.monitors; barWith: [ programs.my-waybar.makeBars =
with config.common.monitors;
barWith: [
# For primary # For primary
(barWith { extraSettings = { output = [ home_4k.meta.connection ]; }; }) (barWith {
extraSettings = {
output = [ home_4k.meta.connection ];
};
})
# For secondary, hide mpd # For secondary, hide mpd
(barWith { showMedia = false; showConnectivity = false; extraSettings = { output = [ home_1440.meta.connection ]; }; }) (barWith {
showMedia = false;
showConnectivity = false;
extraSettings = {
output = [ home_1440.meta.connection ];
};
})
]; ];
# Yellow light! # Yellow light!
@ -72,10 +92,28 @@
# ncmpcpp # ncmpcpp
programs.ncmpcpp.enable = true; programs.ncmpcpp.enable = true;
programs.ncmpcpp.bindings = [ programs.ncmpcpp.bindings = [
{ key = "j"; command = "scroll_down"; } {
{ key = "k"; command = "scroll_up"; } key = "j";
{ key = "J"; command = [ "select_item" "scroll_down" ]; } command = "scroll_down";
{ key = "K"; command = [ "select_item" "scroll_up" ]; } }
{
key = "k";
command = "scroll_up";
}
{
key = "J";
command = [
"select_item"
"scroll_down"
];
}
{
key = "K";
command = [
"select_item"
"scroll_up"
];
}
]; ];
programs.ncmpcpp.settings = { programs.ncmpcpp.settings = {
# General # General
@ -133,4 +171,3 @@
# changes in each release. # changes in each release.
home.stateVersion = "21.05"; home.stateVersion = "21.05";
} }

View file

@ -68,7 +68,15 @@ in
in in
{ {
grammar.src = src; grammar.src = src;
grammar.compile.args = [ "-c" "-fpic" "../parser.c" "../scanner.c" "../unicode.h" "-I" ".." ]; grammar.compile.args = [
"-c"
"-fpic"
"../parser.c"
"../scanner.c"
"../unicode.h"
"-I"
".."
];
queries.src = src; queries.src = src;
queries.path = "queries"; queries.path = "queries";
}; };
@ -79,9 +87,24 @@ in
rev = "0e36bed171768908f331ff7dff9d956bae016efb"; rev = "0e36bed171768908f331ff7dff9d956bae016efb";
hash = "sha256-bpiT3FraOZhJaoiFWAoVJX1O+plnIi8aXOW2LwyU23M="; hash = "sha256-bpiT3FraOZhJaoiFWAoVJX1O+plnIi8aXOW2LwyU23M=";
}; };
grammar.compile.args = [ "-c" "-fpic" "../scanner.cc" "../parser.c" "-I" ".." ]; grammar.compile.args = [
grammar.link.args = [ "-shared" "-fpic" "scanner.o" "parser.o" ]; "-c"
grammar.link.flags = [ "-O3" "-lstdc++" ]; "-fpic"
"../scanner.cc"
"../parser.c"
"-I"
".."
];
grammar.link.args = [
"-shared"
"-fpic"
"scanner.o"
"parser.o"
];
grammar.link.flags = [
"-O3"
"-lstdc++"
];
queries.src = pkgs.fetchFromGitHub { queries.src = pkgs.fetchFromGitHub {
owner = "helix-editor"; owner = "helix-editor";
@ -115,8 +138,18 @@ in
go = { go = {
grammar.src = tree-sitter-go; grammar.src = tree-sitter-go;
grammar.compile.args = [ "-c" "-fpic" "../parser.c" "-I" ".." ]; grammar.compile.args = [
grammar.link.args = [ "-shared" "-fpic" "parser.o" ]; "-c"
"-fpic"
"../parser.c"
"-I"
".."
];
grammar.link.args = [
"-shared"
"-fpic"
"parser.o"
];
queries.src = tree-sitter-go; queries.src = tree-sitter-go;
queries.path = "queries"; queries.path = "queries";
}; };
@ -132,11 +165,20 @@ in
in in
{ {
grammar.src = src; grammar.src = src;
grammar.compile.args = [ "-c" "-fpic" "../parser.c" "-I" ".." ]; grammar.compile.args = [
grammar.link.args = [ "-shared" "-fpic" "parser.o" ]; "-c"
"-fpic"
"../parser.c"
"-I"
".."
];
grammar.link.args = [
"-shared"
"-fpic"
"parser.o"
];
queries.src = src; queries.src = src;
queries.path = "queries"; queries.path = "queries";
}; };
}; };
} }

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
{ {
imports = [ ./common.nix ]; imports = [ ./common.nix ];

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
discord = pkgs.armcord.override { nss = pkgs.nss_latest; }; discord = pkgs.armcord.override { nss = pkgs.nss_latest; };
@ -30,7 +35,9 @@ in
''; '';
# More packages # More packages
home.packages = (with pkgs; [ home.packages = (
with pkgs;
[
mate.mate-terminal mate.mate-terminal
firefox-wayland firefox-wayland
@ -38,7 +45,8 @@ in
discord discord
typora typora
]); ]
);
# Graphical set up # Graphical set up
linux.graphical.type = "wayland"; linux.graphical.type = "wayland";
@ -125,4 +133,3 @@ in
# changes in each release. # changes in each release.
home.stateVersion = "21.05"; home.stateVersion = "21.05";
} }

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let
@ -28,7 +33,10 @@ in
}; };
shell = { shell = {
program = "/bin/sh"; program = "/bin/sh";
args = [ "-ic" "${config.programs.fish.package}/bin/fish" ]; args = [
"-ic"
"${config.programs.fish.package}/bin/fish"
];
}; };
colors = { colors = {
# Default colors # Default colors
@ -57,7 +65,11 @@ in
}; };
key_bindings = [ key_bindings = [
{ key = "C"; mods = "Alt|Control"; action = "SpawnNewInstance"; } {
key = "C";
mods = "Alt|Control";
action = "SpawnNewInstance";
}
]; ];
}; };
}; };

View file

@ -1,4 +1,9 @@
{ pkgs, lib, config, ... }: {
pkgs,
lib,
config,
...
}:
with lib; with lib;
let let
cfg = config.linux.graphical; cfg = config.linux.graphical;
@ -17,7 +22,10 @@ let
end end
''; '';
mkPackageWithDesktopOption = opts: mkOption ({ mkPackageWithDesktopOption =
opts:
mkOption (
{
type = types.submodule { type = types.submodule {
options = { options = {
package = mkOption { package = mkOption {
@ -31,20 +39,39 @@ let
}; };
}; };
}; };
} // opts); }
// opts
);
desktopFileOf = cfg: if cfg.desktopFile == null then "${cfg.package}/share/applications/${cfg.package.pname}.desktop" else cfg.desktopFile; desktopFileOf =
cfg:
if cfg.desktopFile == null then
"${cfg.package}/share/applications/${cfg.package.pname}.desktop"
else
cfg.desktopFile;
in in
{ {
imports = [ ./x11.nix ./wayland.nix ./alacritty.nix ]; imports = [
./x11.nix
./wayland.nix
./alacritty.nix
];
options.linux.graphical = { options.linux.graphical = {
type = mkOption { type = mkOption {
type = types.nullOr (types.enum [ "x11" "wayland" ]); type = types.nullOr (
types.enum [
"x11"
"wayland"
]
);
description = "Enable linux graphical configurations, with either 'x11' or 'wayland'"; description = "Enable linux graphical configurations, with either 'x11' or 'wayland'";
default = null; default = null;
}; };
wallpaper = mkOption { wallpaper = mkOption {
type = types.oneOf [ types.str types.path ]; type = types.oneOf [
types.str
types.path
];
description = "Path to the wallpaper file"; description = "Path to the wallpaper file";
default = ""; default = "";
}; };
@ -59,14 +86,22 @@ in
}; };
defaults = { defaults = {
webBrowser = mkPackageWithDesktopOption { description = "default web browser"; }; webBrowser = mkPackageWithDesktopOption { description = "default web browser"; };
terminal = mkPackageWithDesktopOption { description = "default terminal"; default.package = pkgs.kitty; }; terminal = mkPackageWithDesktopOption {
discord = mkPackageWithDesktopOption { description = "Discord client"; default.package = pkgs.vesktop; }; description = "default terminal";
default.package = pkgs.kitty;
};
discord = mkPackageWithDesktopOption {
description = "Discord client";
default.package = pkgs.vesktop;
};
}; };
}; };
config = mkIf (cfg.type != null) { config = mkIf (cfg.type != null) {
# Packages # Packages
home.packages = (with pkgs; [ home.packages = (
with pkgs;
[
cfg.defaults.webBrowser.package cfg.defaults.webBrowser.package
cfg.defaults.terminal.package cfg.defaults.terminal.package
@ -98,13 +133,14 @@ in
slack slack
zoom-us zoom-us
## CLI stuff ## CLI stuff
dex # .desktop file management, startup dex # .desktop file management, startup
# sct # Display color temperature # sct # Display color temperature
xdg-utils # Open stuff xdg-utils # Open stuff
wifi-indicator wifi-indicator
] ++ cfg.startup); ]
++ cfg.startup
);
# OBS # OBS
programs.obs-studio = { programs.obs-studio = {
@ -129,7 +165,10 @@ in
xdg.mimeApps.enable = true; xdg.mimeApps.enable = true;
xdg.mimeApps.associations.added = { xdg.mimeApps.associations.added = {
"x-scheme-handler/mailto" = [ "thunderbird.desktop" "org.gnome.Evolution.desktop" ]; "x-scheme-handler/mailto" = [
"thunderbird.desktop"
"org.gnome.Evolution.desktop"
];
"application/pdf" = [ "org.gnome.Evince.desktop" ]; "application/pdf" = [ "org.gnome.Evince.desktop" ];
"text/plain" = [ "kakoune.desktop" ]; "text/plain" = [ "kakoune.desktop" ];
@ -154,7 +193,10 @@ in
}; };
xdg.mimeApps.defaultApplications = { xdg.mimeApps.defaultApplications = {
# Email # Email
"x-scheme-handler/mailto" = [ "thunderbird.desktop" "org.gnome.Evolution.desktop" ]; "x-scheme-handler/mailto" = [
"thunderbird.desktop"
"org.gnome.Evolution.desktop"
];
"x-scheme-handler/webcal" = [ "thunderbird.desktop" ]; "x-scheme-handler/webcal" = [ "thunderbird.desktop" ];
"x-scheme-handler/webcals" = [ "thunderbird.desktop" ]; "x-scheme-handler/webcals" = [ "thunderbird.desktop" ];
@ -246,7 +288,10 @@ in
## Qt ## Qt
qt.enable = true; qt.enable = true;
qt.platformTheme.name = "kde"; qt.platformTheme.name = "kde";
qt.platformTheme.package = with pkgs.kdePackages; [ plasma-integration systemsettings ]; qt.platformTheme.package = with pkgs.kdePackages; [
plasma-integration
systemsettings
];
qt.style.package = [ pkgs.kdePackages.breeze ]; qt.style.package = [ pkgs.kdePackages.breeze ];
qt.style.name = "Breeze"; qt.style.name = "Breeze";
@ -267,7 +312,8 @@ in
}; };
autoStartup = listToAttrs (map f cfg.startup); autoStartup = listToAttrs (map f cfg.startup);
in in
autoStartup // { autoStartup
// {
## Polkit UI ## Polkit UI
"autostart/polkit.desktop".text = '' "autostart/polkit.desktop".text = ''
${builtins.readFile "${pkgs.pantheon.pantheon-agent-polkit}/etc/xdg/autostart/io.elementary.desktop.agent-polkit.desktop"} ${builtins.readFile "${pkgs.pantheon.pantheon-agent-polkit}/etc/xdg/autostart/io.elementary.desktop.agent-polkit.desktop"}
@ -304,5 +350,3 @@ in
}; };
}; };
} }

View file

@ -1,18 +1,37 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
notificationModule = { config, pkgs, lib, ... }: notificationModule =
{
config,
pkgs,
lib,
...
}:
let let
swaync = pkgs.swaynotificationcenter; swaync = pkgs.swaynotificationcenter;
in in
with lib; mkIf (config.linux.graphical.type == "wayland") { with lib;
mkIf (config.linux.graphical.type == "wayland") {
services.swaync = { services.swaync = {
enable = true; enable = true;
settings.widgets = [ "inhibitors" "title" "dnd" "mpris" "notifications" ]; settings.widgets = [
"inhibitors"
"title"
"dnd"
"mpris"
"notifications"
];
style = ./swaync.css; style = ./swaync.css;
}; };
programs.my-waybar = { programs.my-waybar = {
extraSettings = [{ extraSettings = [
{
modules-right = mkAfter [ "custom/swaync" ]; modules-right = mkAfter [ "custom/swaync" ];
modules."custom/swaync" = { modules."custom/swaync" = {
tooltip = false; tooltip = false;
@ -34,7 +53,8 @@ let
on-click-right = "${swaync}/bin/swaync-client -d -sw"; on-click-right = "${swaync}/bin/swaync-client -d -sw";
escape = true; escape = true;
}; };
}]; }
];
extraStyle = mkAfter '' extraStyle = mkAfter ''
#custom-swaync { #custom-swaync {
background: #F0FFFF; background: #F0FFFF;
@ -44,7 +64,9 @@ let
}; };
}; };
plasmaModule = { pkgs, ... }: { plasmaModule =
{ pkgs, ... }:
{
home.packages = with pkgs.kdePackages; [ home.packages = with pkgs.kdePackages; [
discover discover
kmail kmail
@ -54,22 +76,31 @@ let
kmail-account-wizard kmail-account-wizard
akonadi-import-wizard akonadi-import-wizard
]; ];
xdg.configFile."plasma-workspace/env/wayland.sh".source = pkgs.writeScript "plasma-wayland-env.sh" '' xdg.configFile."plasma-workspace/env/wayland.sh".source =
pkgs.writeScript "plasma-wayland-env.sh" ''
export NIXOS_OZONE_WL=1 export NIXOS_OZONE_WL=1
''; '';
xdg.dataFile."dbus-1/services/org.freedesktop.Notifications.service".source = "${pkgs.kdePackages.plasma-workspace}/share/dbus-1/services/org.kde.plasma.Notifications.service"; xdg.dataFile."dbus-1/services/org.freedesktop.Notifications.service".source =
"${pkgs.kdePackages.plasma-workspace}/share/dbus-1/services/org.kde.plasma.Notifications.service";
}; };
rofi-rbw-script = pkgs.writeShellApplication { rofi-rbw-script = pkgs.writeShellApplication {
name = "rofi-rbw-script"; name = "rofi-rbw-script";
runtimeInputs = with pkgs; [ rofi wtype rofi-rbw ]; runtimeInputs = with pkgs; [
rofi
wtype
rofi-rbw
];
text = "rofi-rbw"; text = "rofi-rbw";
meta.mainProgram = "rofi-rbw-script"; meta.mainProgram = "rofi-rbw-script";
}; };
in in
with lib; with lib;
{ {
imports = [ notificationModule plasmaModule ]; imports = [
notificationModule
plasmaModule
];
config = mkIf (config.linux.graphical.type == "wayland") { config = mkIf (config.linux.graphical.type == "wayland") {
# Additional packages # Additional packages
home.packages = with pkgs; [ home.packages = with pkgs; [
@ -92,7 +123,12 @@ with lib;
font = "monospace"; font = "monospace";
terminal = "${lib.getExe config.programs.kitty.package}"; terminal = "${lib.getExe config.programs.kitty.package}";
theme = "Paper"; theme = "Paper";
plugins = with pkgs; [ rofi-bluetooth rofi-calc rofi-rbw rofi-power-menu ]; plugins = with pkgs; [
rofi-bluetooth
rofi-calc
rofi-rbw
rofi-power-menu
];
}; };
home.sessionVariables = { home.sessionVariables = {
@ -129,4 +165,3 @@ with lib;
# }; # };
}; };
} }

View file

@ -1,10 +1,18 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.linux.graphical; cfg = config.linux.graphical;
in in
with lib; with lib;
{ {
imports = [ ./x11/hidpi.nix ./x11/i3.nix ]; imports = [
./x11/hidpi.nix
./x11/i3.nix
];
options.linux.graphical.hasDE = mkOption { options.linux.graphical.hasDE = mkOption {
type = types.bool; type = types.bool;
description = "When enabled, disable stuff that already comes with a DE"; description = "When enabled, disable stuff that already comes with a DE";
@ -43,4 +51,3 @@ with lib;
}; };
}; };
} }

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let
@ -18,12 +23,14 @@ let
"10: 10" "10: 10"
]; ];
wsAttrs = builtins.listToAttrs ( wsAttrs = builtins.listToAttrs (
map map (i: {
(i: { name = toString (remainder i 10); value = builtins.elemAt workspaces (i - 1); }) name = toString (remainder i 10);
(range 1 11) value = builtins.elemAt workspaces (i - 1);
}) (range 1 11)
); );
remainder = x: y: x - (builtins.div x y) * y; remainder = x: y: x - (builtins.div x y) * y;
range = from: to: range =
from: to:
let let
f = cur: if cur == to then [ ] else [ cur ] ++ f (cur + 1); f = cur: if cur == to then [ ] else [ cur ] ++ f (cur + 1);
in in
@ -43,7 +50,8 @@ in
"${wsAttrs."1"}" = [ { class = "^firefox$"; } ]; "${wsAttrs."1"}" = [ { class = "^firefox$"; } ];
"${wsAttrs."2"}" = [ { class = "^discord$"; } ]; "${wsAttrs."2"}" = [ { class = "^discord$"; } ];
}; };
config.bars = [{ config.bars = [
{
command = "${pkgs.i3-gaps}/bin/i3bar -t"; command = "${pkgs.i3-gaps}/bin/i3bar -t";
statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ~/.config/i3status-rust/config-default.toml"; statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ~/.config/i3status-rust/config-default.toml";
position = "top"; position = "top";
@ -52,15 +60,42 @@ in
statusline = "#ffffff"; statusline = "#ffffff";
separator = "#666666"; separator = "#666666";
focusedWorkspace = { background = "#4c7899"; border = "#285577"; text = "#ffffff"; }; focusedWorkspace = {
activeWorkspace = { background = "#333333"; border = "#5f676a"; text = "#ffffff"; }; background = "#4c7899";
inactiveWorkspace = { background = "#333333"; border = "#222222"; text = "#888888"; }; border = "#285577";
urgentWorkspace = { background = "#2f343a"; border = "#900000"; text = "#ffffff"; }; text = "#ffffff";
bindingMode = { background = "#2f343a"; border = "#900000"; text = "#ffffff"; };
}; };
}]; activeWorkspace = {
background = "#333333";
border = "#5f676a";
text = "#ffffff";
};
inactiveWorkspace = {
background = "#333333";
border = "#222222";
text = "#888888";
};
urgentWorkspace = {
background = "#2f343a";
border = "#900000";
text = "#ffffff";
};
bindingMode = {
background = "#2f343a";
border = "#900000";
text = "#ffffff";
};
};
}
];
config.focus.newWindow = "none"; config.focus.newWindow = "none";
config.fonts = { names = [ "FantasqueSansMono Nerd Font Mono" "monospace" ]; size = 11.0; }; config.fonts = {
names = [
"FantasqueSansMono Nerd Font Mono"
"monospace"
];
size = 11.0;
};
config.gaps.outer = 5; config.gaps.outer = 5;
config.gaps.inner = 5; config.gaps.inner = 5;
config.gaps.smartGaps = true; config.gaps.smartGaps = true;
@ -69,7 +104,8 @@ in
config.window.titlebar = false; config.window.titlebar = false;
# Keybindings # Keybindings
config.keybindings = lib.mkOptionDefault ({ config.keybindings = lib.mkOptionDefault (
{
## vim-style movements ## vim-style movements
"${mod}+h" = "focus left"; "${mod}+h" = "focus left";
"${mod}+j" = "focus down"; "${mod}+j" = "focus down";
@ -85,9 +121,10 @@ in
## Run ## Run
"${mod}+r" = "exec ${pkgs.dmenu}/bin/dmenu_run"; "${mod}+r" = "exec ${pkgs.dmenu}/bin/dmenu_run";
"${mod}+d" = "exec i3-dmenu-desktop --dmenu='${pkgs.dmenu}/bin/dmenu -i'"; "${mod}+d" = "exec i3-dmenu-desktop --dmenu='${pkgs.dmenu}/bin/dmenu -i'";
} // ( }
builtins.listToAttrs (lib.flatten (map // (builtins.listToAttrs (
(key: [ lib.flatten (
map (key: [
{ {
name = "${mod}+${key}"; name = "${mod}+${key}";
value = "workspace ${builtins.getAttr key wsAttrs}"; value = "workspace ${builtins.getAttr key wsAttrs}";
@ -96,26 +133,28 @@ in
name = "${mod}+Shift+${key}"; name = "${mod}+Shift+${key}";
value = "move to workspace ${builtins.getAttr key wsAttrs}"; value = "move to workspace ${builtins.getAttr key wsAttrs}";
} }
]) ]) (builtins.attrNames wsAttrs)
(builtins.attrNames wsAttrs)) )
))); ))
);
# Workspace # Workspace
config.defaultWorkspace = "workspace ${builtins.getAttr "1" wsAttrs}"; config.defaultWorkspace = "workspace ${builtins.getAttr "1" wsAttrs}";
config.startup = [ config.startup =
[
{ command = "firefox"; } { command = "firefox"; }
{ command = "discord"; } { command = "discord"; }
{ command = "dex -ae i3"; } { command = "dex -ae i3"; }
{ command = "ibus-daemon -drxR"; } { command = "ibus-daemon -drxR"; }
] ++ ]
( ++ (
if (config.linux.graphical.wallpaper != "") if (config.linux.graphical.wallpaper != "") then
then [{ command = "${pkgs.feh}/bin/feh --bg-fill ${config.linux.graphical.wallpaper}"; }] [ { command = "${pkgs.feh}/bin/feh --bg-fill ${config.linux.graphical.wallpaper}"; } ]
else [ ] else
[ ]
); );
}; };
# i3status # i3status
programs.i3status-rust.enable = true; programs.i3status-rust.enable = true;
programs.i3status-rust.bars.default = { programs.i3status-rust.bars.default = {
@ -154,5 +193,3 @@ in
}; };
}; };
} }

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
{ {

View file

@ -1,24 +1,42 @@
# A monitor list and common sway set up # A monitor list and common sway set up
{ config, pkgs, lib, ... }: with lib; {
config,
pkgs,
lib,
...
}:
with lib;
let let
monitors = { monitors = {
# Internal # Internal
"framework" = { "framework" = {
name = "BOE 0x0BCA Unknown"; name = "BOE 0x0BCA Unknown";
meta.mode = { width = 2256; height = 1504; refresh = 60.0; }; meta.mode = {
width = 2256;
height = 1504;
refresh = 60.0;
};
scale = 1.25; scale = 1.25;
}; };
"yoga" = { "yoga" = {
name = "AU Optronics 0xD291 Unknown"; name = "AU Optronics 0xD291 Unknown";
meta.connection = "eDP-1"; meta.connection = "eDP-1";
meta.mode = { width = 1920; height = 1080; refresh = 60.026; }; meta.mode = {
width = 1920;
height = 1080;
refresh = 60.026;
};
scale = 1; scale = 1;
}; };
# External # External
## Work @ EPFL ## Work @ EPFL
"work" = { "work" = {
name = "LG Electronics LG ULTRAFINE 301MAXSGHD10"; name = "LG Electronics LG ULTRAFINE 301MAXSGHD10";
meta.mode = { width = 3840; height = 2160; refresh = 60.0; }; meta.mode = {
width = 3840;
height = 2160;
refresh = 60.0;
};
scale = 1.25; scale = 1.25;
}; };
"home_4k" = { "home_4k" = {
@ -27,8 +45,15 @@ let
adaptive_sync = "on"; adaptive_sync = "on";
meta = { meta = {
connection = "DP-2"; connection = "DP-2";
mode = { width = 3840; height = 2160; refresh = 60.0; }; mode = {
fixedPosition = { x = 0; y = 0; }; width = 3840;
height = 2160;
refresh = 60.0;
};
fixedPosition = {
x = 0;
y = 0;
};
niriName = "PNP(AOC) U28G2G6B PPYP2JA000013"; niriName = "PNP(AOC) U28G2G6B PPYP2JA000013";
}; };
}; };
@ -37,15 +62,26 @@ let
adaptive_sync = "on"; adaptive_sync = "on";
meta = { meta = {
connection = "DP-3"; connection = "DP-3";
mode = { width = 2560; height = 1440; refresh = 165.0; }; mode = {
fixedPosition = { x = 2560; y = 0; }; width = 2560;
height = 1440;
refresh = 165.0;
};
fixedPosition = {
x = 2560;
y = 0;
};
niriName = "PNP(AOC) Q27G2G3R3B VXJP6HA000442"; niriName = "PNP(AOC) Q27G2G3R3B VXJP6HA000442";
}; };
}; };
"viewsonic_1080" = { "viewsonic_1080" = {
name = "ViewSonic Corporation XG2402 SERIES V4K182501054"; name = "ViewSonic Corporation XG2402 SERIES V4K182501054";
meta.mode = { width = 1920; height = 1080; refresh = 144.0; }; meta.mode = {
width = 1920;
height = 1080;
refresh = 144.0;
};
adaptive_sync = "on"; adaptive_sync = "on";
}; };
@ -53,11 +89,19 @@ let
eachMonitor = _name: monitor: { eachMonitor = _name: monitor: {
name = monitor.name; name = monitor.name;
value = builtins.removeAttrs monitor [ "scale" "name" "meta" ] // (lib.optionalAttrs (monitor ? scale) { value =
builtins.removeAttrs monitor [
"scale"
"name"
"meta"
]
// (lib.optionalAttrs (monitor ? scale) {
scale = toString monitor.scale; scale = toString monitor.scale;
}) // { })
// {
mode = with monitor.meta.mode; "${toString width}x${toString height}@${toString refresh}Hz"; mode = with monitor.meta.mode; "${toString width}x${toString height}@${toString refresh}Hz";
} // (lib.optionalAttrs (monitor.meta ? fixedPosition) { }
// (lib.optionalAttrs (monitor.meta ? fixedPosition) {
position = with monitor.meta.fixedPosition; "${toString x} ${toString y}"; position = with monitor.meta.fixedPosition; "${toString x} ${toString y}";
}); });
}; };
@ -73,4 +117,3 @@ in
mapAttrs' eachMonitor config.common.monitors mapAttrs' eachMonitor config.common.monitors
); );
} }

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
with lib; with lib;
let let
@ -91,10 +96,13 @@ in
# Add an extra syntax_color config # Add an extra syntax_color config
xdg.configFile."broot/conf.toml".source = mkOverride 1 ( xdg.configFile."broot/conf.toml".source = mkOverride 1 (
tomlFormat.generate "broot-config" (with config.programs.broot; { tomlFormat.generate "broot-config" (
with config.programs.broot;
{
inherit (settings) verbs modal skin; inherit (settings) verbs modal skin;
syntax_theme = "base16-ocean.light"; syntax_theme = "base16-ocean.light";
}) }
)
); );
}; };
} }

View file

@ -1,11 +1,20 @@
{ config, options, pkgs, lib, ... }: {
config,
options,
pkgs,
lib,
...
}:
with lib; with lib;
let let
cfg = config.programs.my-kakoune; cfg = config.programs.my-kakoune;
in in
{ {
imports = [ ./fish-session.nix ./tree-sitter.nix ]; imports = [
./fish-session.nix
./tree-sitter.nix
];
options.programs.my-kakoune = { options.programs.my-kakoune = {
enable = mkEnableOption "My version of the kakoune configuration"; enable = mkEnableOption "My version of the kakoune configuration";
@ -38,7 +47,11 @@ in
let let
kakouneFaces = kakouneFaces =
let let
txt = strings.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") cfg.extraFaces)); txt = strings.concatStringsSep "\n" (
builtins.attrValues (
builtins.mapAttrs (name: face: "face global ${name} \"${face}\"") cfg.extraFaces
)
);
in in
pkgs.writeText "faces.kak" txt; pkgs.writeText "faces.kak" txt;
in in
@ -51,15 +64,13 @@ in
# Load faces # Load faces
source ${kakouneFaces} source ${kakouneFaces}
''; '';
} // lib.mapAttrs' }
(name: attrs: { // lib.mapAttrs' (name: attrs: {
name = "kak/autoload/${name}"; name = "kak/autoload/${name}";
value = attrs // { value = attrs // {
target = "kak/autoload/${name}"; target = "kak/autoload/${name}";
}; };
}) }) cfg.autoloadFile;
cfg.autoloadFile;
xdg.dataFile."kak".source = "${cfg.package}/share/kak"; xdg.dataFile."kak".source = "${cfg.package}/share/kak";
}; };
} }

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
with lib; with lib;
let let

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
with lib; with lib;
let let
cfg = config.programs.my-kakoune.tree-sitter; cfg = config.programs.my-kakoune.tree-sitter;
@ -14,14 +19,44 @@ let
default = "src"; default = "src";
}; };
grammar.compile = { grammar.compile = {
command = mkOption { type = types.str; default = "${pkgs.gcc}/bin/gcc"; }; command = mkOption {
args = mkOption { type = types.listOf types.str; default = [ "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ]; }; type = types.str;
flags = mkOption { type = types.listOf types.str; default = [ "-O3" ]; }; default = "${pkgs.gcc}/bin/gcc";
};
args = mkOption {
type = types.listOf types.str;
default = [
"-c"
"-fpic"
"../parser.c"
"../scanner.c"
"-I"
".."
];
};
flags = mkOption {
type = types.listOf types.str;
default = [ "-O3" ];
};
}; };
grammar.link = { grammar.link = {
command = mkOption { type = types.str; default = "${pkgs.gcc}/bin/gcc"; }; command = mkOption {
args = mkOption { type = types.listOf types.str; default = [ "-shared" "-fpic" "parser.o" "scanner.o" ]; }; type = types.str;
flags = mkOption { type = types.listOf types.str; default = [ "-O3" ]; }; default = "${pkgs.gcc}/bin/gcc";
};
args = mkOption {
type = types.listOf types.str;
default = [
"-shared"
"-fpic"
"parser.o"
"scanner.o"
];
};
flags = mkOption {
type = types.listOf types.str;
default = [ "-O3" ];
};
}; };
queries.src = mkOption { queries.src = mkOption {
type = types.package; type = types.package;
@ -34,12 +69,27 @@ let
}; };
}; };
mkGrammarPackage = mkGrammarPackage =
{ name {
, src name,
, grammarPath ? "src" src,
, grammarCompileArgs ? [ "-O3" "-c" "-fpic" "../parser.c" "../scanner.c" "-I" ".." ] grammarPath ? "src",
, grammarLinkArgs ? [ "-shared" "-fpic" "parser.o" "scanner.o" ] grammarCompileArgs ? [
}: pkgs.stdenv.mkDerivation { "-O3"
"-c"
"-fpic"
"../parser.c"
"../scanner.c"
"-I"
".."
],
grammarLinkArgs ? [
"-shared"
"-fpic"
"parser.o"
"scanner.o"
],
}:
pkgs.stdenv.mkDerivation {
inherit src; inherit src;
name = "kak-tree-sitter-grammar-${name}.so"; name = "kak-tree-sitter-grammar-${name}.so";
version = "latest"; version = "latest";
@ -215,13 +265,20 @@ in
toTs = name: "ts_${strings.concatStringsSep "_" (strings.splitString "." name)}"; toTs = name: "ts_${strings.concatStringsSep "_" (strings.splitString "." name)}";
toScm = name: strings.concatStringsSep "." (strings.splitString "_" name); toScm = name: strings.concatStringsSep "." (strings.splitString "_" name);
definedFaces = attrsets.mapAttrs' (name: value: { inherit value; name = toTs name; }) allGroups; definedFaces = attrsets.mapAttrs' (name: value: {
aliasFaces = attrsets.mapAttrs' (name: value: { name = toTs name; value = "@${toTs value}"; }) aliases; inherit value;
name = toTs name;
}) allGroups;
aliasFaces = attrsets.mapAttrs' (name: value: {
name = toTs name;
value = "@${toTs value}";
}) aliases;
faces = attrsets.recursiveUpdate definedFaces aliasFaces; faces = attrsets.recursiveUpdate definedFaces aliasFaces;
toml = pkgs.formats.toml { }; toml = pkgs.formats.toml { };
toLanguageConf = name: lang: with lang; { toLanguageConf =
name: lang: with lang; {
grammar = { grammar = {
source.local.path = mkGrammarPackage { source.local.path = mkGrammarPackage {
inherit name; inherit name;
@ -234,7 +291,10 @@ in
compile_args = grammar.compile.args; compile_args = grammar.compile.args;
compile_flags = grammar.compile.flags; compile_flags = grammar.compile.flags;
link = grammar.link.command; link = grammar.link.command;
link_args = grammar.link.args ++ [ "-o" "${name}.so" ]; link_args = grammar.link.args ++ [
"-o"
"${name}.so"
];
link_flags = grammar.link.flags; link_flags = grammar.link.flags;
}; };
queries = rec { queries = rec {
@ -244,13 +304,14 @@ in
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
assertions = with lib.asserts; ([ ] assertions =
++ attrsets.mapAttrsToList with lib.asserts;
(name: _: { (
[ ]
++ attrsets.mapAttrsToList (name: _: {
assertion = (!(builtins.hasAttr name allGroups)); assertion = (!(builtins.hasAttr name allGroups));
message = "${name} was both defined and aliased"; message = "${name} was both defined and aliased";
}) }) aliases
aliases
); );
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
@ -271,4 +332,3 @@ in
}; };
} }

View file

@ -1,9 +1,15 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.nki.programs.kitty; cfg = config.nki.programs.kitty;
cmd = "cmd"; cmd = "cmd";
in in
with lib; { with lib;
{
programs.kitty = mkIf (cfg.enable && pkgs.stdenv.isDarwin) { programs.kitty = mkIf (cfg.enable && pkgs.stdenv.isDarwin) {
# Darwin-specific setup # Darwin-specific setup
@ -24,4 +30,3 @@ with lib; {
}; };
}; };
} }

View file

@ -1,13 +1,28 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.nki.programs.kitty; cfg = config.nki.programs.kitty;
theme = { lib, options, config, ... }: { theme =
{
lib,
options,
config,
...
}:
{
programs.kitty = lib.mkIf config.nki.programs.kitty.enable ( programs.kitty = lib.mkIf config.nki.programs.kitty.enable (
if builtins.hasAttr "themeFile" options.programs.kitty then { if builtins.hasAttr "themeFile" options.programs.kitty then
{
themeFile = "ayu_light"; themeFile = "ayu_light";
} else { }
else
{
theme = "Ayu Light"; theme = "Ayu Light";
} }
); );
@ -15,7 +30,12 @@ let
in in
with lib; with lib;
{ {
imports = [ theme ./darwin.nix ./linux.nix ./tabs.nix ]; imports = [
theme
./darwin.nix
./linux.nix
./tabs.nix
];
options.nki.programs.kitty = { options.nki.programs.kitty = {
enable = mkEnableOption "Enable kitty"; enable = mkEnableOption "Enable kitty";
@ -73,10 +93,13 @@ with lib;
let let
# Background color and transparency # Background color and transparency
background = background =
if isNull cfg.background then { if isNull cfg.background then
{
background_opacity = "0.93"; background_opacity = "0.93";
dynamic_background_opacity = true; dynamic_background_opacity = true;
} else { }
else
{
background_image = "${cfg.background}"; background_image = "${cfg.background}";
background_image_layout = "scaled"; background_image_layout = "scaled";
background_tint = "0.85"; background_tint = "0.85";
@ -123,4 +146,3 @@ with lib;
''; '';
}; };
} }

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.nki.programs.kitty; cfg = config.nki.programs.kitty;
in in

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.nki.programs.kitty; cfg = config.nki.programs.kitty;
@ -7,7 +12,8 @@ in
with lib; with lib;
{ {
programs.kitty = mkIf cfg.enableTabs { programs.kitty = mkIf cfg.enableTabs {
keybindings = { keybindings =
{
"${cmd}+t" = "new_tab_with_cwd"; "${cmd}+t" = "new_tab_with_cwd";
"${cmd}+shift+t" = "new_tab"; "${cmd}+shift+t" = "new_tab";
"${cmd}+shift+o" = "launch --cwd=current --location=vsplit"; "${cmd}+shift+o" = "launch --cwd=current --location=vsplit";
@ -30,10 +36,9 @@ with lib;
"${cmd}+f" = "toggle_layout stack"; "${cmd}+f" = "toggle_layout stack";
} }
# Tab bindings # Tab bindings
// builtins.listToAttrs // builtins.listToAttrs (
(map map (x: attrsets.nameValuePair "${cmd}+${toString x}" "goto_tab ${toString x}") (lists.range 1 9)
(x: attrsets.nameValuePair "${cmd}+${toString x}" "goto_tab ${toString x}") );
(lists.range 1 9));
settings = { settings = {
# Tab settings # Tab settings
tab_bar_edge = "top"; tab_bar_edge = "top";

View file

@ -1,4 +1,10 @@
{ config, osConfig, lib, pkgs, ... }: {
config,
osConfig,
lib,
pkgs,
...
}:
let let
cfg = config.programs.my-niri; cfg = config.programs.my-niri;
@ -26,16 +32,33 @@ in
lock-command = lib.mkOption { lock-command = lib.mkOption {
type = lib.types.listOf lib.types.str; type = lib.types.listOf lib.types.str;
description = "The command to lock the screen"; description = "The command to lock the screen";
default = [ "${pkgs.swaylock}/bin/swaylock" ] default =
++ (if wallpaper == "" then [ "" ] else [ "-i" "${wallpaper}" "-s" "fill" ]) [ "${pkgs.swaylock}/bin/swaylock" ]
++ [ "-l" "-k" ]; ++ (
if wallpaper == "" then
[ "" ]
else
[
"-i"
"${wallpaper}"
"-s"
"fill"
]
)
++ [
"-l"
"-k"
];
}; };
workspaces = lib.mkOption { workspaces = lib.mkOption {
type = lib.types.attrsOf type = lib.types.attrsOf (
(lib.types.submodule { lib.types.submodule {
options = { options = {
name = lib.mkOption { type = lib.types.str; description = "workspace name"; }; name = lib.mkOption {
type = lib.types.str;
description = "workspace name";
};
fixed = lib.mkOption { fixed = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = true; default = true;
@ -47,7 +70,8 @@ in
description = "Default monitor to spawn workspace in"; description = "Default monitor to spawn workspace in";
}; };
}; };
}); }
);
description = "A mapping of ordering to workspace names, for fixed workspaces"; description = "A mapping of ordering to workspace names, for fixed workspaces";
}; };
}; };
@ -55,17 +79,39 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.my-niri.workspaces = { programs.my-niri.workspaces = {
# Default workspaces, always there # Default workspaces, always there
"01" = { name = "🌏 web"; }; "01" = {
"02" = { name = "💬 chat"; }; name = "🌏 web";
"03" = { name = " code"; }; };
"04" = { name = "🎶 music"; }; "02" = {
"05" = { name = "🔧 extra"; }; name = "💬 chat";
"06" = { name = "🧰 6"; }; };
"07" = { name = "🔩 7"; }; "03" = {
"08" = { name = "🛠 8"; }; name = " code";
"09" = { name = "🔨 9"; }; };
"10" = { name = "🎲 misc"; }; "04" = {
"99" = { name = "📧 Email"; }; name = "🎶 music";
};
"05" = {
name = "🔧 extra";
};
"06" = {
name = "🧰 6";
};
"07" = {
name = "🔩 7";
};
"08" = {
name = "🛠 8";
};
"09" = {
name = "🔨 9";
};
"10" = {
name = "🎲 misc";
};
"99" = {
name = "📧 Email";
};
}; };
systemd.user.services.swaync.Install.WantedBy = [ "niri.service" ]; systemd.user.services.swaync.Install.WantedBy = [ "niri.service" ];
systemd.user.services.swaync.Unit.After = [ "niri.service" ]; systemd.user.services.swaync.Unit.After = [ "niri.service" ];
@ -84,7 +130,10 @@ in
Unit = { Unit = {
Description = "XWayland Client for niri"; Description = "XWayland Client for niri";
PartOf = [ "xwayland.target" ]; PartOf = [ "xwayland.target" ];
Before = [ "xwayland.target" "xdg-desktop-autostart.target" ]; Before = [
"xwayland.target"
"xdg-desktop-autostart.target"
];
After = [ "niri.service" ]; After = [ "niri.service" ];
}; };
Install.WantedBy = [ "niri.service" ]; Install.WantedBy = [ "niri.service" ];
@ -97,16 +146,20 @@ in
}; };
programs.niri.settings = { programs.niri.settings = {
environment = { environment =
{
QT_QPA_PLATFORM = "wayland"; QT_QPA_PLATFORM = "wayland";
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
QT_IM_MODULE = "fcitx"; QT_IM_MODULE = "fcitx";
# export NIXOS_OZONE_WL=1 # Until text-input is merged # export NIXOS_OZONE_WL=1 # Until text-input is merged
DISPLAY = xwayland-display; DISPLAY = xwayland-display;
} // lib.optionalAttrs osConfig.services.desktopManager.plasma6.enable { }
// lib.optionalAttrs osConfig.services.desktopManager.plasma6.enable {
XDG_MENU_PREFIX = "plasma-"; XDG_MENU_PREFIX = "plasma-";
}; };
input.keyboard.xkb = { layout = "jp"; }; input.keyboard.xkb = {
layout = "jp";
};
input.touchpad = lib.mkIf cfg.enableLaptop { input.touchpad = lib.mkIf cfg.enableLaptop {
tap = true; tap = true;
dwt = true; dwt = true;
@ -138,9 +191,25 @@ in
spawn-at-startup = [ spawn-at-startup = [
# Wallpaper # Wallpaper
{ command = [ (lib.getExe pkgs.swaybg) "-i" "${wallpaper}" "-m" "fill" ]; } {
command = [
(lib.getExe pkgs.swaybg)
"-i"
"${wallpaper}"
"-m"
"fill"
];
}
# Waybar # Waybar
{ command = [ "systemctl" "--user" "start" "xdg-desktop-portal-gtk.service" "xdg-desktop-portal.service" ]; } {
command = [
"systemctl"
"--user"
"start"
"xdg-desktop-portal-gtk.service"
"xdg-desktop-portal.service"
];
}
]; ];
layout = { layout = {
@ -154,11 +223,24 @@ in
focus-ring = { focus-ring = {
width = 4; width = 4;
active.gradient = { from = "#00447AFF"; to = "#71C4FFAA"; angle = 45; }; active.gradient = {
from = "#00447AFF";
to = "#71C4FFAA";
angle = 45;
};
inactive.color = "#505050"; inactive.color = "#505050";
}; };
border.enable = false; border.enable = false;
struts = let v = 8; in { left = v; right = v; bottom = v; top = v; }; struts =
let
v = 8;
in
{
left = v;
right = v;
bottom = v;
top = v;
};
}; };
prefer-no-csd = true; prefer-no-csd = true;
@ -166,18 +248,31 @@ in
workspaces = workspaces =
let let
fixedWorkspaces = lib.filterAttrs (_: w: w.fixed) cfg.workspaces; fixedWorkspaces = lib.filterAttrs (_: w: w.fixed) cfg.workspaces;
workspaceConfig = lib.mapAttrs workspaceConfig = lib.mapAttrs (
(_: w: { inherit (w) name; } // (lib.optionalAttrs (w.monitor != null) { _: w:
{
inherit (w) name;
}
// (lib.optionalAttrs (w.monitor != null) {
open-on-output = w.monitor; open-on-output = w.monitor;
})) })
fixedWorkspaces; ) fixedWorkspaces;
in in
workspaceConfig; workspaceConfig;
window-rules = [ window-rules = [
# Rounded Corners # Rounded Corners
{ {
geometry-corner-radius = let v = 8.0; in { bottom-left = v; bottom-right = v; top-left = v; top-right = v; }; geometry-corner-radius =
let
v = 8.0;
in
{
bottom-left = v;
bottom-right = v;
top-left = v;
top-right = v;
};
clip-to-geometry = true; clip-to-geometry = true;
} }
# Workspace assignments # Workspace assignments
@ -185,9 +280,18 @@ in
open-on-workspace = cfg.workspaces."01".name; open-on-workspace = cfg.workspaces."01".name;
open-maximized = true; open-maximized = true;
matches = [ matches = [
{ at-startup = true; app-id = "^firefox$"; } {
{ at-startup = true; app-id = "^librewolf$"; } at-startup = true;
{ at-startup = true; app-id = "^zen$"; } app-id = "^firefox$";
}
{
at-startup = true;
app-id = "^librewolf$";
}
{
at-startup = true;
app-id = "^zen$";
}
]; ];
} }
{ {
@ -268,14 +372,38 @@ in
"Mod+Shift+P".action = spawn "rofi-rbw-script"; "Mod+Shift+P".action = spawn "rofi-rbw-script";
# Audio and Volume # Audio and Volume
"XF86AudioPrev" = { action = spawn playerctl "previous"; allow-when-locked = true; }; "XF86AudioPrev" = {
"XF86AudioPlay" = { action = spawn playerctl "play-pause"; allow-when-locked = true; }; action = spawn playerctl "previous";
"Shift+XF86AudioPlay" = { action = spawn playerctl "stop"; allow-when-locked = true; }; allow-when-locked = true;
"XF86AudioNext" = { action = spawn playerctl "next"; allow-when-locked = true; }; };
"XF86AudioRecord" = { action = spawn amixer "-q" "set" "Capture" "toggle"; allow-when-locked = true; }; "XF86AudioPlay" = {
"XF86AudioMute" = { action = spawn amixer "-q" "set" "Master" "toggle"; allow-when-locked = true; }; action = spawn playerctl "play-pause";
"XF86AudioLowerVolume" = { action = spawn amixer "-q" "set" "Master" "3%-"; allow-when-locked = true; }; allow-when-locked = true;
"XF86AudioRaiseVolume" = { action = spawn amixer "-q" "set" "Master" "3%+"; allow-when-locked = true; }; };
"Shift+XF86AudioPlay" = {
action = spawn playerctl "stop";
allow-when-locked = true;
};
"XF86AudioNext" = {
action = spawn playerctl "next";
allow-when-locked = true;
};
"XF86AudioRecord" = {
action = spawn amixer "-q" "set" "Capture" "toggle";
allow-when-locked = true;
};
"XF86AudioMute" = {
action = spawn amixer "-q" "set" "Master" "toggle";
allow-when-locked = true;
};
"XF86AudioLowerVolume" = {
action = spawn amixer "-q" "set" "Master" "3%-";
allow-when-locked = true;
};
"XF86AudioRaiseVolume" = {
action = spawn amixer "-q" "set" "Master" "3%+";
allow-when-locked = true;
};
# Backlight # Backlight
"XF86MonBrightnessDown".action = spawn brightnessctl "s" "10%-"; "XF86MonBrightnessDown".action = spawn brightnessctl "s" "10%-";
@ -320,10 +448,22 @@ in
"Mod+Ctrl+O".action = move-workspace-up; "Mod+Ctrl+O".action = move-workspace-up;
# Mouse bindings # Mouse bindings
"Mod+WheelScrollDown" = { action = focus-workspace-down; cooldown-ms = 150; }; "Mod+WheelScrollDown" = {
"Mod+WheelScrollUp" = { action = focus-workspace-up; cooldown-ms = 150; }; action = focus-workspace-down;
"Mod+Ctrl+WheelScrollDown" = { action = move-column-to-workspace-down; cooldown-ms = 150; }; cooldown-ms = 150;
"Mod+Ctrl+WheelScrollUp" = { action = move-column-to-workspace-up; cooldown-ms = 150; }; };
"Mod+WheelScrollUp" = {
action = focus-workspace-up;
cooldown-ms = 150;
};
"Mod+Ctrl+WheelScrollDown" = {
action = move-column-to-workspace-down;
cooldown-ms = 150;
};
"Mod+Ctrl+WheelScrollUp" = {
action = move-column-to-workspace-up;
cooldown-ms = 150;
};
"Mod+WheelScrollRight".action = focus-column-right; "Mod+WheelScrollRight".action = focus-column-right;
"Mod+WheelScrollLeft".action = focus-column-left; "Mod+WheelScrollLeft".action = focus-column-left;
@ -338,26 +478,66 @@ in
# #
# For example, with 2 workspaces + 1 empty, indices 3, 4, 5 and so on # For example, with 2 workspaces + 1 empty, indices 3, 4, 5 and so on
# will all refer to the 3rd workspace. # will all refer to the 3rd workspace.
"Mod+1" = lib.mkIf cfg.workspaces."01".fixed { action = focus-workspace (cfg.workspaces."01".name); }; "Mod+1" = lib.mkIf cfg.workspaces."01".fixed {
"Mod+2" = lib.mkIf cfg.workspaces."02".fixed { action = focus-workspace (cfg.workspaces."02".name); }; action = focus-workspace (cfg.workspaces."01".name);
"Mod+3" = lib.mkIf cfg.workspaces."03".fixed { action = focus-workspace (cfg.workspaces."03".name); }; };
"Mod+4" = lib.mkIf cfg.workspaces."04".fixed { action = focus-workspace (cfg.workspaces."04".name); }; "Mod+2" = lib.mkIf cfg.workspaces."02".fixed {
"Mod+5" = lib.mkIf cfg.workspaces."05".fixed { action = focus-workspace (cfg.workspaces."05".name); }; action = focus-workspace (cfg.workspaces."02".name);
"Mod+6" = lib.mkIf cfg.workspaces."06".fixed { action = focus-workspace (cfg.workspaces."06".name); }; };
"Mod+7" = lib.mkIf cfg.workspaces."07".fixed { action = focus-workspace (cfg.workspaces."07".name); }; "Mod+3" = lib.mkIf cfg.workspaces."03".fixed {
"Mod+8" = lib.mkIf cfg.workspaces."08".fixed { action = focus-workspace (cfg.workspaces."08".name); }; action = focus-workspace (cfg.workspaces."03".name);
"Mod+9" = lib.mkIf cfg.workspaces."09".fixed { action = focus-workspace (cfg.workspaces."09".name); }; };
"Mod+0" = lib.mkIf cfg.workspaces."10".fixed { action = focus-workspace (cfg.workspaces."10".name); }; "Mod+4" = lib.mkIf cfg.workspaces."04".fixed {
"Mod+Shift+1" = lib.mkIf cfg.workspaces."01".fixed { action = move-column-to-workspace (cfg.workspaces."01".name); }; action = focus-workspace (cfg.workspaces."04".name);
"Mod+Shift+2" = lib.mkIf cfg.workspaces."02".fixed { action = move-column-to-workspace (cfg.workspaces."02".name); }; };
"Mod+Shift+3" = lib.mkIf cfg.workspaces."03".fixed { action = move-column-to-workspace (cfg.workspaces."03".name); }; "Mod+5" = lib.mkIf cfg.workspaces."05".fixed {
"Mod+Shift+4" = lib.mkIf cfg.workspaces."04".fixed { action = move-column-to-workspace (cfg.workspaces."04".name); }; action = focus-workspace (cfg.workspaces."05".name);
"Mod+Shift+5" = lib.mkIf cfg.workspaces."05".fixed { action = move-column-to-workspace (cfg.workspaces."05".name); }; };
"Mod+Shift+6" = lib.mkIf cfg.workspaces."06".fixed { action = move-column-to-workspace (cfg.workspaces."06".name); }; "Mod+6" = lib.mkIf cfg.workspaces."06".fixed {
"Mod+Shift+7" = lib.mkIf cfg.workspaces."07".fixed { action = move-column-to-workspace (cfg.workspaces."07".name); }; action = focus-workspace (cfg.workspaces."06".name);
"Mod+Shift+8" = lib.mkIf cfg.workspaces."08".fixed { action = move-column-to-workspace (cfg.workspaces."08".name); }; };
"Mod+Shift+9" = lib.mkIf cfg.workspaces."09".fixed { action = move-column-to-workspace (cfg.workspaces."09".name); }; "Mod+7" = lib.mkIf cfg.workspaces."07".fixed {
"Mod+Shift+0" = lib.mkIf cfg.workspaces."10".fixed { action = move-column-to-workspace (cfg.workspaces."10".name); }; action = focus-workspace (cfg.workspaces."07".name);
};
"Mod+8" = lib.mkIf cfg.workspaces."08".fixed {
action = focus-workspace (cfg.workspaces."08".name);
};
"Mod+9" = lib.mkIf cfg.workspaces."09".fixed {
action = focus-workspace (cfg.workspaces."09".name);
};
"Mod+0" = lib.mkIf cfg.workspaces."10".fixed {
action = focus-workspace (cfg.workspaces."10".name);
};
"Mod+Shift+1" = lib.mkIf cfg.workspaces."01".fixed {
action = move-column-to-workspace (cfg.workspaces."01".name);
};
"Mod+Shift+2" = lib.mkIf cfg.workspaces."02".fixed {
action = move-column-to-workspace (cfg.workspaces."02".name);
};
"Mod+Shift+3" = lib.mkIf cfg.workspaces."03".fixed {
action = move-column-to-workspace (cfg.workspaces."03".name);
};
"Mod+Shift+4" = lib.mkIf cfg.workspaces."04".fixed {
action = move-column-to-workspace (cfg.workspaces."04".name);
};
"Mod+Shift+5" = lib.mkIf cfg.workspaces."05".fixed {
action = move-column-to-workspace (cfg.workspaces."05".name);
};
"Mod+Shift+6" = lib.mkIf cfg.workspaces."06".fixed {
action = move-column-to-workspace (cfg.workspaces."06".name);
};
"Mod+Shift+7" = lib.mkIf cfg.workspaces."07".fixed {
action = move-column-to-workspace (cfg.workspaces."07".name);
};
"Mod+Shift+8" = lib.mkIf cfg.workspaces."08".fixed {
action = move-column-to-workspace (cfg.workspaces."08".name);
};
"Mod+Shift+9" = lib.mkIf cfg.workspaces."09".fixed {
action = move-column-to-workspace (cfg.workspaces."09".name);
};
"Mod+Shift+0" = lib.mkIf cfg.workspaces."10".fixed {
action = move-column-to-workspace (cfg.workspaces."10".name);
};
"Mod+asciicircum".action = focus-workspace (cfg.workspaces."99".name); "Mod+asciicircum".action = focus-workspace (cfg.workspaces."99".name);
"Mod+Shift+asciicircum".action = move-column-to-workspace (cfg.workspaces."99".name); "Mod+Shift+asciicircum".action = move-column-to-workspace (cfg.workspaces."99".name);
@ -392,4 +572,3 @@ in
}; };
}; };
} }

View file

@ -1,4 +1,11 @@
{ pkgs, lib, options, config, osConfig, ... }: {
pkgs,
lib,
options,
config,
osConfig,
...
}:
with lib; with lib;
let let
cfg = config.programs.my-sway; cfg = config.programs.my-sway;
@ -22,12 +29,14 @@ let
mail = "📧 Email"; mail = "📧 Email";
}; };
wsAttrs = builtins.listToAttrs ( wsAttrs = builtins.listToAttrs (
map map (i: {
(i: { name = toString (remainder i 10); value = builtins.elemAt workspaces (i - 1); }) name = toString (remainder i 10);
(range 1 11) value = builtins.elemAt workspaces (i - 1);
}) (range 1 11)
); );
remainder = x: y: x - (builtins.div x y) * y; remainder = x: y: x - (builtins.div x y) * y;
range = from: to: range =
from: to:
let let
f = cur: if cur == to then [ ] else [ cur ] ++ f (cur + 1); f = cur: if cur == to then [ ] else [ cur ] ++ f (cur + 1);
in in
@ -64,7 +73,10 @@ in
default = true; default = true;
}; };
wallpaper = mkOption { wallpaper = mkOption {
type = types.oneOf [ types.path types.str ]; type = types.oneOf [
types.path
types.str
];
description = "Path to the wallpaper to be used"; description = "Path to the wallpaper to be used";
default = config.linux.graphical.wallpaper; default = config.linux.graphical.wallpaper;
}; };
@ -83,14 +95,20 @@ in
lockCmd = mkOption { lockCmd = mkOption {
type = types.str; type = types.str;
description = "The screen lock command"; description = "The screen lock command";
default = "${pkgs.swaylock}/bin/swaylock" default =
"${pkgs.swaylock}/bin/swaylock"
+ (if cfg.wallpaper == "" then "" else " -i ${cfg.wallpaper} -s fill") + (if cfg.wallpaper == "" then "" else " -i ${cfg.wallpaper} -s fill")
+ " -l -k"; + " -l -k";
}; };
}; };
config.systemd.user.targets.sway-session = mkIf cfg.enable { config.systemd.user.targets.sway-session = mkIf cfg.enable {
Unit.Before = [ "tray.target" "xwayland.target" "xdg-desktop-portal.service" "xdg-desktop-autostart.target" ]; Unit.Before = [
"tray.target"
"xwayland.target"
"xdg-desktop-portal.service"
"xdg-desktop-autostart.target"
];
Unit.Upholds = [ "waybar.service" ]; Unit.Upholds = [ "waybar.service" ];
Unit.Wants = [ "xdg-desktop-autostart.target" ]; Unit.Wants = [ "xdg-desktop-autostart.target" ];
}; };
@ -107,11 +125,14 @@ in
enable = true; enable = true;
package = cfg.package; package = cfg.package;
systemd.enable = true; systemd.enable = true;
systemd.variables = options.wayland.windowManager.sway.systemd.variables.default ++ [ systemd.variables =
options.wayland.windowManager.sway.systemd.variables.default
++ [
"PATH" # for portals "PATH" # for portals
"XDG_DATA_DIRS" # For extra icons "XDG_DATA_DIRS" # For extra icons
"XDG_DATA_HOME" # For extra icons "XDG_DATA_HOME" # For extra icons
] ++ lib.optionals osConfig.services.desktopManager.plasma6.enable [ ]
++ lib.optionals osConfig.services.desktopManager.plasma6.enable [
"XDG_MENU_PREFIX" "XDG_MENU_PREFIX"
]; ];
# systemd.extraCommands = options.wayland.windowManager.sway.systemd.extraCommands.default # systemd.extraCommands = options.wayland.windowManager.sway.systemd.extraCommands.default
@ -137,7 +158,8 @@ in
### Seats ### Seats
# #
# Cursor # Cursor
seat."*".xcursor_theme = "${config.home.pointerCursor.name} ${toString config.home.pointerCursor.size}"; seat."*".xcursor_theme =
"${config.home.pointerCursor.name} ${toString config.home.pointerCursor.size}";
### Programs ### Programs
# #
@ -158,7 +180,8 @@ in
# #
# Main modifier # Main modifier
modifier = mod; modifier = mod;
keybindings = { keybindings =
{
### Default Bindings ### Default Bindings
# #
## App management ## App management
@ -206,7 +229,8 @@ in
"${mod}+space" = "exec rofi -show drun"; "${mod}+space" = "exec rofi -show drun";
"${mod}+tab" = "exec ${./rofi-window.py}"; "${mod}+tab" = "exec ${./rofi-window.py}";
"${mod}+shift+p" = "exec rofi-rbw-script"; "${mod}+shift+p" = "exec rofi-rbw-script";
} // { }
// {
## Splits ## Splits
"${mod}+v" = "split v"; "${mod}+v" = "split v";
"${mod}+Shift+v" = "split h"; "${mod}+Shift+v" = "split h";
@ -230,12 +254,16 @@ in
## Backlight ## Backlight
"XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s 10%-"; "XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s 10%-";
"XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s 10%+"; "XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s 10%+";
"Shift+XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl -d kbd_backlight s 25%-"; "Shift+XF86MonBrightnessDown" =
"Shift+XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl -d kbd_backlight s 25%+"; "exec ${pkgs.brightnessctl}/bin/brightnessctl -d kbd_backlight s 25%-";
} // "Shift+XF86MonBrightnessUp" =
"exec ${pkgs.brightnessctl}/bin/brightnessctl -d kbd_backlight s 25%+";
}
//
# Map the workspaces # Map the workspaces
(builtins.listToAttrs (lib.flatten (map (builtins.listToAttrs (
(key: [ lib.flatten (
map (key: [
{ {
name = "${mod}+${key}"; name = "${mod}+${key}";
value = "workspace ${builtins.getAttr key wsAttrs}"; value = "workspace ${builtins.getAttr key wsAttrs}";
@ -244,14 +272,15 @@ in
name = "${mod}+Shift+${key}"; name = "${mod}+Shift+${key}";
value = "move to workspace ${builtins.getAttr key wsAttrs}"; value = "move to workspace ${builtins.getAttr key wsAttrs}";
} }
]) ]) (builtins.attrNames wsAttrs)
(builtins.attrNames wsAttrs)) )
)) // ))
{ // {
# Extra workspaces # Extra workspaces
"${mod}+asciicircum" = "workspace ${extraWorkspaces.mail}"; "${mod}+asciicircum" = "workspace ${extraWorkspaces.mail}";
"${mod}+shift+asciicircum" = "move to workspace ${extraWorkspaces.mail}"; "${mod}+shift+asciicircum" = "move to workspace ${extraWorkspaces.mail}";
} // }
//
# Move workspaces between outputs # Move workspaces between outputs
{ {
"${mod}+ctrl+h" = "move workspace to output left"; "${mod}+ctrl+h" = "move workspace to output left";
@ -261,7 +290,10 @@ in
### Fonts ### Fonts
# #
fonts = { fonts = {
names = [ "monospace" "FontAwesome5Free" ]; names = [
"monospace"
"FontAwesome5Free"
];
size = cfg.fontSize; size = cfg.fontSize;
}; };
@ -298,9 +330,16 @@ in
]; ];
}; };
# Commands # Commands
window.commands = [ window.commands =
{ criteria = { title = ".*"; }; command = "inhibit_idle fullscreen"; } [
] ++ ( {
criteria = {
title = ".*";
};
command = "inhibit_idle fullscreen";
}
]
++ (
# Floating assignments # Floating assignments
let let
criterias = [ criterias = [
@ -309,7 +348,10 @@ in
{ class = ".*float.*"; } { class = ".*float.*"; }
{ title = "Extension: .*Bitwarden.*"; } { title = "Extension: .*Bitwarden.*"; }
]; ];
toCommand = criteria: { inherit criteria; command = "floating enable"; }; toCommand = criteria: {
inherit criteria;
command = "floating enable";
};
in in
map toCommand criterias map toCommand criterias
); );
@ -334,20 +376,28 @@ in
# swaynag # swaynag
swaynag.enable = true; swaynag.enable = true;
# Environment Variables # Environment Variables
extraSessionCommands = '' extraSessionCommands =
''
export QT_QPA_PLATFORM=wayland export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION="1" export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
export QT_IM_MODULE=fcitx export QT_IM_MODULE=fcitx
export GTK_IM_MODULE=fcitx # Til text-input is merged export GTK_IM_MODULE=fcitx # Til text-input is merged
# export NIXOS_OZONE_WL=1 # Until text-input is merged # export NIXOS_OZONE_WL=1 # Until text-input is merged
'' + (if config.services.gnome-keyring.enable then '' ''
+ (
if config.services.gnome-keyring.enable then
''
# gnome-keyring # gnome-keyring
if type gnome-keyring-daemon >/dev/null; then if type gnome-keyring-daemon >/dev/null; then
eval `gnome-keyring-daemon` eval `gnome-keyring-daemon`
export SSH_AUTH_SOCK export SSH_AUTH_SOCK
fi fi
'' else "") + lib.optionalString osConfig.services.desktopManager.plasma6.enable '' ''
else
""
)
+ lib.optionalString osConfig.services.desktopManager.plasma6.enable ''
export XDG_MENU_PREFIX=plasma- export XDG_MENU_PREFIX=plasma-
''; '';
# Extra # Extra
@ -355,7 +405,9 @@ in
wrapperFeatures.gtk = true; wrapperFeatures.gtk = true;
extraConfig = extraConfig =
(if cfg.enableLaptop then '' (
if cfg.enableLaptop then
''
# Lock screen on lid close # Lock screen on lid close
bindswitch lid:off exec ${cfg.lockCmd} bindswitch lid:off exec ${cfg.lockCmd}
@ -363,7 +415,11 @@ in
bindgesture swipe:3:right workspace prev bindgesture swipe:3:right workspace prev
bindgesture swipe:3:left workspace next bindgesture swipe:3:left workspace next
bindgesture swipe:3:up exec ${./rofi-window.py} bindgesture swipe:3:up exec ${./rofi-window.py}
'' else "") + '' ''
else
""
)
+ ''
## swayfx stuff ## swayfx stuff
# Rounded corners # Rounded corners
corner_radius 5 corner_radius 5
@ -378,10 +434,10 @@ in
# Blur # Blur
for_window [app_id=".*kitty.*"] blur enable for_window [app_id=".*kitty.*"] blur enable
blur_xray disable blur_xray disable
'' + '' ''
+ ''
# Enable portal stuff # Enable portal stuff
exec ${pkgs.writeShellScript "start-portals.sh" '' exec ${pkgs.writeShellScript "start-portals.sh" ''''}
''}
''; '';
}; };
@ -393,20 +449,28 @@ in
# { timeout = 15 * 60; command = cfg.lockCmd; } # { timeout = 15 * 60; command = cfg.lockCmd; }
]; ];
events = [ events = [
{ event = "lock"; command = cfg.lockCmd; } {
{ event = "before-sleep"; command = cfg.lockCmd; } event = "lock";
command = cfg.lockCmd;
}
{
event = "before-sleep";
command = cfg.lockCmd;
}
]; ];
}; };
config.home.packages = mkIf cfg.enable (with pkgs; [ config.home.packages = mkIf cfg.enable (
with pkgs;
[
# Needed for QT_QPA_PLATFORM # Needed for QT_QPA_PLATFORM
kdePackages.qtwayland kdePackages.qtwayland
# For waybar # For waybar
font-awesome font-awesome
]); ]
);
config.programs.rofi = mkIf cfg.enable { config.programs.rofi = mkIf cfg.enable {
font = lib.mkForce "monospace ${toString cfg.fontSize}"; font = lib.mkForce "monospace ${toString cfg.fontSize}";
}; };
} }

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let
cfg = config.programs.my-sway; cfg = config.programs.my-sway;
@ -6,15 +11,22 @@ let
# Set up an ibus script # Set up an ibus script
ibusNext = ( ibusNext = (
let let
input-methods = [ "xkb:us::eng" "mozc-jp" "Bamboo" ]; input-methods = [
next = m: "xkb:us::eng"
"mozc-jp"
"Bamboo"
];
next =
m:
let let
nextRec = l: nextRec =
if (length l == 1) l:
then head input-methods if (length l == 1) then
else if (m == head l) head input-methods
then (head (tail l)) else if (m == head l) then
else nextRec (tail l); (head (tail l))
else
nextRec (tail l);
in in
nextRec input-methods; nextRec input-methods;
changeTo = m: '' changeTo = m: ''
@ -52,4 +64,3 @@ in
}; };
}; };
} }

View file

@ -1,4 +1,9 @@
{ lib, config, pkgs, ... }: {
lib,
config,
pkgs,
...
}:
let let
cfg = config.programs.my-waybar; cfg = config.programs.my-waybar;
in in
@ -47,7 +52,16 @@ in
}; };
config.programs.waybar = config.programs.waybar =
let let
barWith = { showMedia ? true, showConnectivity ? true, extraSettings ? { }, ... }: lib.mkMerge ([{ barWith =
{
showMedia ? true,
showConnectivity ? true,
extraSettings ? { },
...
}:
lib.mkMerge (
[
{
layer = "top"; layer = "top";
position = "top"; position = "top";
modules-left = [ modules-left = [
@ -64,14 +78,20 @@ in
++ [ ++ [
"tray" "tray"
"pulseaudio" "pulseaudio"
] ++ lib.optionals showConnectivity [ ]
++ lib.optionals showConnectivity [
"bluetooth" "bluetooth"
"network" "network"
] ++ [ ]
++ [
"cpu" "cpu"
"memory" "memory"
"temperature" "temperature"
] ++ lib.optionals cfg.enableLaptopBars [ "battery" "battery#bat2" ] ]
++ lib.optionals cfg.enableLaptopBars [
"battery"
"battery#bat2"
]
++ [ ++ [
"clock" "clock"
]; ];
@ -161,8 +181,14 @@ in
"backlight" = { "backlight" = {
# device = "acpi_video1"; # device = "acpi_video1";
format = "{percent}% {icon}"; format = "{percent}% {icon}";
states = [ 0 50 ]; states = [
format-icons = [ "" "" ]; 0
50
];
format-icons = [
""
""
];
}; };
"battery" = lib.mkIf cfg.enableLaptopBars { "battery" = lib.mkIf cfg.enableLaptopBars {
states = { states = {
@ -173,7 +199,13 @@ in
format = "{capacity}% {icon}"; format = "{capacity}% {icon}";
# format-good = ""; # An empty format will hide the module # format-good = ""; # An empty format will hide the module
# format-full = ""; # format-full = "";
format-icons = [ "" "" "" "" "" ]; format-icons = [
""
""
""
""
""
];
}; };
"battery#bat2" = lib.mkIf cfg.enableLaptopBars { "battery#bat2" = lib.mkIf cfg.enableLaptopBars {
bat = "BAT2"; bat = "BAT2";
@ -209,12 +241,16 @@ in
phone = ""; phone = "";
portable = ""; portable = "";
car = ""; car = "";
default = [ "" "" ]; default = [
""
""
];
}; };
on-click = "${pkgs.pavucontrol}/bin/pavucontrol"; on-click = "${pkgs.pavucontrol}/bin/pavucontrol";
}; };
"mpd" = { "mpd" = {
"format" = "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) 🎧"; "format" =
"{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) 🎧";
"format-disconnected" = "Disconnected 🎧"; "format-disconnected" = "Disconnected 🎧";
"format-stopped" = "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped 🎧"; "format-stopped" = "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped 🎧";
"interval" = 2; "interval" = 2;
@ -249,20 +285,24 @@ in
"Paused" = " "; "Paused" = " ";
}; };
"max-length" = 80; "max-length" = 80;
"exec" = "${lib.getExe pkgs.playerctl} -a metadata --format '{\"text\": \"{{artist}} - {{markup_escape(title)}}\", \"tooltip\": \"{{playerName}} : {{markup_escape(title)}}\", \"alt\": \"{{status}}\", \"class\": \"{{status}}\"}' -F"; "exec" =
"${lib.getExe pkgs.playerctl} -a metadata --format '{\"text\": \"{{artist}} - {{markup_escape(title)}}\", \"tooltip\": \"{{playerName}} : {{markup_escape(title)}}\", \"alt\": \"{{status}}\", \"class\": \"{{status}}\"}' -F";
"on-click" = "${lib.getExe pkgs.playerctl} play-pause"; "on-click" = "${lib.getExe pkgs.playerctl} play-pause";
}; };
}; };
}] ++ }
cfg.extraSettings ]
++ [ extraSettings ]); ++ cfg.extraSettings
++ [ extraSettings ]
);
in in
lib.mkIf cfg.enable { lib.mkIf cfg.enable {
enable = true; enable = true;
systemd.enable = true; systemd.enable = true;
systemd.target = "sway-session.target"; systemd.target = "sway-session.target";
settings = cfg.makeBars barWith; settings = cfg.makeBars barWith;
style = '' style =
''
* { * {
border: none; border: none;
border-radius: 0; border-radius: 0;
@ -423,6 +463,7 @@ in
background-color: teal; background-color: teal;
color: white; color: white;
} }
'' + cfg.extraStyle; ''
+ cfg.extraStyle;
}; };
} }

View file

@ -1,8 +1,16 @@
{ pkgs, lib, config, ... }: {
pkgs,
lib,
config,
...
}:
let let
openconnect-epfl = pkgs.writeShellApplication { openconnect-epfl = pkgs.writeShellApplication {
name = "openconnect-epfl"; name = "openconnect-epfl";
runtimeInputs = with pkgs; [ openconnect rbw ]; runtimeInputs = with pkgs; [
openconnect
rbw
];
text = '' text = ''
METHOD="Microsoft Entra ID" METHOD="Microsoft Entra ID"
RBW_ENTRY="EPFL Microsoft Auth" RBW_ENTRY="EPFL Microsoft Auth"
@ -20,4 +28,3 @@ in
{ {
home.packages = [ openconnect-epfl ]; home.packages = [ openconnect-epfl ];
} }

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
{ {
imports = [ imports = [
@ -56,9 +61,11 @@
powerprofilesctl set $new_profile powerprofilesctl set $new_profile
''; '';
in in
[{ [
{
modules."battery"."on-click" = change-mode; modules."battery"."on-click" = change-mode;
}]; }
];
# input-remapping # input-remapping
xdg.configFile."autostart/input-remapper-autoload.desktop".source = xdg.configFile."autostart/input-remapper-autoload.desktop".source =
@ -85,7 +92,10 @@
position = "0,${toString (builtins.floor ((2160 / work.scale - 1200) + 1200 / 3))}"; position = "0,${toString (builtins.floor ((2160 / work.scale - 1200) + 1200 / 3))}";
status = "enable"; status = "enable";
} }
{ criteria = work.name; position = "1920,0"; } {
criteria = work.name;
position = "1920,0";
}
]; ];
} }
{ {
@ -111,4 +121,3 @@
# changes in each release. # changes in each release.
home.stateVersion = "21.05"; home.stateVersion = "21.05";
} }

View file

@ -1,4 +1,10 @@
{ pkgs, options, config, lib, ... }: {
pkgs,
options,
config,
lib,
...
}:
let let
iio-sway = pkgs.stdenv.mkDerivation { iio-sway = pkgs.stdenv.mkDerivation {
@ -11,7 +17,11 @@ let
hash = "sha256-JGacKajslCOvd/BFfFSf7s1/hgF6rJqJ6H6xNnsuMb4="; hash = "sha256-JGacKajslCOvd/BFfFSf7s1/hgF6rJqJ6H6xNnsuMb4=";
}; };
buildInputs = with pkgs; [ dbus ]; buildInputs = with pkgs; [ dbus ];
nativeBuildInputs = with pkgs; [ meson ninja pkg-config ]; nativeBuildInputs = with pkgs; [
meson
ninja
pkg-config
];
meta.mainProgram = "iio-sway"; meta.mainProgram = "iio-sway";
}; };
in in
@ -31,10 +41,13 @@ in
home.homeDirectory = "/home/nki"; home.homeDirectory = "/home/nki";
# More packages # More packages
home.packages = (with pkgs; [ home.packages = (
with pkgs;
[
# Note-taking # Note-taking
rnote rnote
]); ]
);
# Graphical set up # Graphical set up
linux.graphical.type = "wayland"; linux.graphical.type = "wayland";
@ -65,7 +78,9 @@ in
programs.my-niri.enable = true; programs.my-niri.enable = true;
programs.my-niri.enableLaptop = true; programs.my-niri.enableLaptop = true;
# Assign some of the workspaces to big screen # Assign some of the workspaces to big screen
programs.my-niri.workspaces = lib.genAttrs [ "06" "07" "08" "09" "10" ] (_: { monitor = config.common.monitors.work.name; }); programs.my-niri.workspaces = lib.genAttrs [ "06" "07" "08" "09" "10" ] (_: {
monitor = config.common.monitors.work.name;
});
programs.niri.settings = { programs.niri.settings = {
# input.keyboard.xkb.options = "ctrl:swapcaps"; # input.keyboard.xkb.options = "ctrl:swapcaps";
input.mouse = lib.mkForce { input.mouse = lib.mkForce {
@ -115,14 +130,24 @@ in
{ {
profile.name = "work-both"; profile.name = "work-both";
profile.outputs = [ profile.outputs = [
{ criteria = "eDP-1"; position = "0,${toString (builtins.floor ((2160 / work.scale - 1200) + 1200 / 3))}"; status = "enable"; } {
{ criteria = work.name; position = "1920,0"; } criteria = "eDP-1";
position = "0,${toString (builtins.floor ((2160 / work.scale - 1200) + 1200 / 3))}";
status = "enable";
}
{
criteria = work.name;
position = "1920,0";
}
]; ];
} }
{ {
profile.name = "work-one"; profile.name = "work-one";
profile.outputs = [ profile.outputs = [
{ criteria = "eDP-1"; status = "disable"; } {
criteria = "eDP-1";
status = "disable";
}
{ criteria = work.name; } { criteria = work.name; }
]; ];
} }
@ -139,4 +164,3 @@ in
# changes in each release. # changes in each release.
home.stateVersion = "21.05"; home.stateVersion = "21.05";
} }

View file

@ -2,7 +2,9 @@
let let
# osu-pkg = pkgs.unstable.osu-lazer-bin; # osu-pkg = pkgs.unstable.osu-lazer-bin;
osu-pkg = with pkgs; with lib; osu-pkg =
with pkgs;
with lib;
appimageTools.wrapType2 rec { appimageTools.wrapType2 rec {
pname = "osu-lazer-bin"; pname = "osu-lazer-bin";
version = "2025.321.0"; version = "2025.321.0";
@ -13,7 +15,8 @@ let
extraPkgs = pkgs: with pkgs; [ icu ]; extraPkgs = pkgs: with pkgs; [ icu ];
extraInstallCommands = extraInstallCommands =
let contents = appimageTools.extract { inherit pname version src; }; let
contents = appimageTools.extract { inherit pname version src; };
in in
'' ''
mv -v $out/bin/${pname} $out/bin/osu\! mv -v $out/bin/${pname} $out/bin/osu\!
@ -30,4 +33,3 @@ in
xdg.mimeApps.defaultApplications."x-scheme-handler/osu" = "osu!.desktop"; xdg.mimeApps.defaultApplications."x-scheme-handler/osu" = "osu!.desktop";
# home.packages = [ pkgs.osu-lazer ]; # home.packages = [ pkgs.osu-lazer ];
} }

View file

@ -2,11 +2,15 @@
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
{ {
imports = imports = [
[
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
# Fonts # Fonts
@ -14,13 +18,24 @@
# Encrypted DNS # Encrypted DNS
../modules/services/edns ../modules/services/edns
# Override base mesa # Override base mesa
({ ... }: { nixpkgs.overlays = lib.mkBefore [ (final: prev: { mesa = prev.mesa.override { enableOpenCL = true; meson = final.unstable.meson; }; }) ]; }) (
{ ... }:
{
nixpkgs.overlays = lib.mkBefore [
(final: prev: {
mesa = prev.mesa.override {
enableOpenCL = true;
meson = final.unstable.meson;
};
})
];
}
)
]; ];
# time.timeZone = lib.mkForce "Asia/Ho_Chi_Minh"; # time.timeZone = lib.mkForce "Asia/Ho_Chi_Minh";
services.xserver.desktopManager.plasma5.enable = true; services.xserver.desktopManager.plasma5.enable = true;
# Asahi kernel configuration # Asahi kernel configuration
hardware.asahi = { hardware.asahi = {
peripheralFirmwareDirectory = ./firmware; peripheralFirmwareDirectory = ./firmware;
@ -46,9 +61,9 @@
hash = "sha256-IcKKe1RA8sCaUfWK71ELzF15YaBS3DjoYhNMIWiQ5Jw="; hash = "sha256-IcKKe1RA8sCaUfWK71ELzF15YaBS3DjoYhNMIWiQ5Jw=";
}; };
patches = lib.forEach attrs.patches (p: patches = lib.forEach attrs.patches (
if lib.hasSuffix "opencl.patch" p p: if lib.hasSuffix "opencl.patch" p then ./mesa-asahi-edge/opencl.patch else p
then ./mesa-asahi-edge/opencl.patch else p); );
}); });
}) })
]; ];
@ -145,4 +160,3 @@
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.05"; # Did you read the comment? system.stateVersion = "22.05"; # Did you read the comment?
} }

View file

@ -1,11 +1,16 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: {
config,
lib,
pkgs,
modulesPath,
...
}:
{ {
imports = imports = [
[
(modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
]; ];
@ -14,20 +19,21 @@
boot.kernelModules = [ ]; boot.kernelModules = [ ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" = {
{
device = "/dev/disk/by-uuid/ebb6bf2e-2d7f-4fa6-88cb-751fdd174ef9"; device = "/dev/disk/by-uuid/ebb6bf2e-2d7f-4fa6-88cb-751fdd174ef9";
fsType = "ext4"; fsType = "ext4";
}; };
fileSystems."/boot" = fileSystems."/boot" = {
{
device = "/dev/disk/by-uuid/19BC-1BE8"; device = "/dev/disk/by-uuid/19BC-1BE8";
fsType = "vfat"; fsType = "vfat";
}; };
swapDevices = [ swapDevices = [
{ device = "/swap"; size = 16 * 1024; } {
device = "/swap";
size = 16 * 1024;
}
]; ];
# nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux"; # nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";

View file

@ -1,11 +1,15 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let
cfg = config.cloud.authentik; cfg = config.cloud.authentik;
mkImage = mkImage = { imageName, imageDigest, ... }: "${imageName}@${imageDigest}";
{ imageName, imageDigest, ... }: "${imageName}@${imageDigest}";
# If we can pullImage we can just do # If we can pullImage we can just do
# mkImage = pkgs.dockerTools.pullImage; # mkImage = pkgs.dockerTools.pullImage;
@ -62,7 +66,10 @@ in
image = images.postgresql; image = images.postgresql;
restart = "unless-stopped"; restart = "unless-stopped";
healthcheck = { healthcheck = {
test = [ "CMD-SHELL" "pg_isready -d $\${POSTGRES_DB} -U $\${POSTGRES_USER}" ]; test = [
"CMD-SHELL"
"pg_isready -d $\${POSTGRES_DB} -U $\${POSTGRES_USER}"
];
start_period = "20s"; start_period = "20s";
interval = "30s"; interval = "30s";
retries = 5; retries = 5;
@ -73,14 +80,20 @@ in
POSTGRES_USER = "authentik"; POSTGRES_USER = "authentik";
POSTGRES_DB = "authentik"; POSTGRES_DB = "authentik";
}; };
env_file = [ cfg.envFile "${postgresEnv}" ]; env_file = [
cfg.envFile
"${postgresEnv}"
];
}; };
services.redis.service = { services.redis.service = {
image = images.redis; image = images.redis;
command = "--save 60 1 --loglevel warning"; command = "--save 60 1 --loglevel warning";
restart = "unless-stopped"; restart = "unless-stopped";
healthcheck = { healthcheck = {
test = [ "CMD-SHELL" "redis-cli ping | grep PONG" ]; test = [
"CMD-SHELL"
"redis-cli ping | grep PONG"
];
start_period = "20s"; start_period = "20s";
interval = "30s"; interval = "30s";
retries = 5; retries = 5;
@ -102,7 +115,10 @@ in
AUTHENTIK_POSTGRESQL__USER = "authentik"; AUTHENTIK_POSTGRESQL__USER = "authentik";
AUTHENTIK_POSTGRESQL__NAME = "authentik"; AUTHENTIK_POSTGRESQL__NAME = "authentik";
}; };
env_file = [ cfg.envFile "${authentikEnv}" ]; env_file = [
cfg.envFile
"${authentikEnv}"
];
ports = [ ports = [
"127.0.0.1:${toString cfg.port}:9000" "127.0.0.1:${toString cfg.port}:9000"
]; ];
@ -124,7 +140,10 @@ in
AUTHENTIK_POSTGRESQL__USER = "authentik"; AUTHENTIK_POSTGRESQL__USER = "authentik";
AUTHENTIK_POSTGRESQL__NAME = "authentik"; AUTHENTIK_POSTGRESQL__NAME = "authentik";
}; };
env_file = [ cfg.envFile "${authentikEnv}" ]; env_file = [
cfg.envFile
"${authentikEnv}"
];
user = "root"; user = "root";
}; };
docker-compose.volumes = { docker-compose.volumes = {
@ -134,4 +153,3 @@ in
}; };
}; };
} }

View file

@ -1,4 +1,9 @@
{ pkgs, lib, config, ... }: {
pkgs,
lib,
config,
...
}:
with lib; with lib;
let let

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.cloud.conduit; cfg = config.cloud.conduit;
@ -33,7 +38,8 @@ with lib;
}; };
instances = mkOption { instances = mkOption {
type = types.attrsOf (types.submodule { type = types.attrsOf (
types.submodule {
options = { options = {
host = mkOption { host = mkOption {
type = types.str; type = types.str;
@ -57,32 +63,37 @@ with lib;
type = types.int; type = types.int;
}; };
}; };
}); }
);
}; };
}; };
config.systemd.services = mkIf cfg.enable config.systemd.services = mkIf cfg.enable (
(lib.attrsets.mapAttrs' lib.attrsets.mapAttrs' (
(name: instance: lib.attrsets.nameValuePair "matrix-conduit-${name}" name: instance:
( lib.attrsets.nameValuePair "matrix-conduit-${name}" (
let let
srvName = "matrix-conduit-${name}"; srvName = "matrix-conduit-${name}";
format = pkgs.formats.toml { }; format = pkgs.formats.toml { };
server_name = if instance.server_name == "" then instance.host else instance.server_name; server_name = if instance.server_name == "" then instance.host else instance.server_name;
configFile = format.generate "conduit.toml" (lib.attrsets.recursiveUpdate defaultConfig { configFile = format.generate "conduit.toml" (
lib.attrsets.recursiveUpdate defaultConfig {
global.server_name = server_name; global.server_name = server_name;
global.port = instance.port; global.port = instance.port;
global.allow_registration = instance.allow_registration; global.allow_registration = instance.allow_registration;
global.database_path = "/mnt/data/${srvName}/"; global.database_path = "/mnt/data/${srvName}/";
global.well_known_client = "https://${instance.host}"; global.well_known_client = "https://${instance.host}";
global.well_known_server = "${instance.host}:443"; global.well_known_server = "${instance.host}:443";
}); }
);
in in
{ {
description = "Conduit Matrix Server (for ${server_name})"; description = "Conduit Matrix Server (for ${server_name})";
documentation = [ "https://gitlab.com/famedly/conduit/" ]; documentation = [ "https://gitlab.com/famedly/conduit/" ];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
environment = { CONDUIT_CONFIG = configFile; }; environment = {
CONDUIT_CONFIG = configFile;
};
serviceConfig = { serviceConfig = {
DynamicUser = true; DynamicUser = true;
User = "${srvName}"; User = "${srvName}";
@ -97,7 +108,10 @@ with lib;
PrivateDevices = true; PrivateDevices = true;
PrivateMounts = true; PrivateMounts = true;
PrivateUsers = true; PrivateUsers = true;
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ]; RestrictAddressFamilies = [
"AF_INET"
"AF_INET6"
];
RestrictNamespaces = true; RestrictNamespaces = true;
RestrictRealtime = true; RestrictRealtime = true;
SystemCallArchitectures = "native"; SystemCallArchitectures = "native";
@ -113,15 +127,16 @@ with lib;
StartLimitBurst = 5; StartLimitBurst = 5;
}; };
} }
)) )
cfg.instances); ) cfg.instances
);
config.cloud.traefik.hosts = mkIf cfg.enable ( config.cloud.traefik.hosts = mkIf cfg.enable (
(lib.attrsets.mapAttrs' (lib.attrsets.mapAttrs' (
(name: instance: lib.attrsets.nameValuePair "conduit-${name}" ({ name: instance:
lib.attrsets.nameValuePair "conduit-${name}" ({
inherit (instance) host port noCloudflare; inherit (instance) host port noCloudflare;
})) })
cfg.instances) ) cfg.instances)
); );
} }

View file

@ -1,9 +1,15 @@
{ pkgs, lib, config, ... }: {
pkgs,
lib,
config,
...
}:
let let
cfg = config.cloud.conduit.heisenbridge; cfg = config.cloud.conduit.heisenbridge;
cfgConduit = config.cloud.conduit; cfgConduit = config.cloud.conduit;
in in
with lib; { with lib;
{
options.cloud.conduit.heisenbridge = { options.cloud.conduit.heisenbridge = {
enable = mkEnableOption "Enable heisenbridge for conduit"; enable = mkEnableOption "Enable heisenbridge for conduit";
package = mkPackageOption pkgs "heisenbridge" { }; package = mkPackageOption pkgs "heisenbridge" { };
@ -23,17 +29,26 @@ with lib; {
}; };
config = mkIf cfg.enable ( config = mkIf cfg.enable (
let let
cfgFile = if cfg.port == null then cfg.appserviceFile else cfgFile =
if cfg.port == null then
cfg.appserviceFile
else
pkgs.runCommand "heisenbridge-config" { } '' pkgs.runCommand "heisenbridge-config" { } ''
cp ${cfg.appserviceFile} $out cp ${cfg.appserviceFile} $out
${pkgs.sd}/bin/sd '^url: .*$' "url: http://127.0.0.1:${cfg.port}" ${pkgs.sd}/bin/sd '^url: .*$' "url: http://127.0.0.1:${cfg.port}"
''; '';
listenArgs = lists.optionals (cfg.port != null) [ "--listen-port" (toString cfg.port) ]; listenArgs = lists.optionals (cfg.port != null) [
"--listen-port"
(toString cfg.port)
];
in in
{ {
systemd.services.heisenbridge = { systemd.services.heisenbridge = {
description = "Matrix<->IRC bridge"; description = "Matrix<->IRC bridge";
requires = [ "matrix-conduit-nkagami.service" "matrix-synapse.service" ]; # So the registration file can be used by Synapse requires = [
"matrix-conduit-nkagami.service"
"matrix-synapse.service"
]; # So the registration file can be used by Synapse
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
serviceConfig = rec { serviceConfig = rec {
@ -77,12 +92,18 @@ with lib; {
RemoveIPC = true; RemoveIPC = true;
UMask = "0077"; UMask = "0077";
CapabilityBoundingSet = [ "CAP_CHOWN" ] ++ optional (cfg.port != null && cfg.port < 1024) "CAP_NET_BIND_SERVICE"; CapabilityBoundingSet = [
"CAP_CHOWN"
] ++ optional (cfg.port != null && cfg.port < 1024) "CAP_NET_BIND_SERVICE";
AmbientCapabilities = CapabilityBoundingSet; AmbientCapabilities = CapabilityBoundingSet;
NoNewPrivileges = true; NoNewPrivileges = true;
LockPersonality = true; LockPersonality = true;
RestrictRealtime = true; RestrictRealtime = true;
SystemCallFilter = [ "@system-service" "~@privileged" "@chown" ]; SystemCallFilter = [
"@system-service"
"~@privileged"
"@chown"
];
SystemCallArchitectures = "native"; SystemCallArchitectures = "native";
RestrictAddressFamilies = "AF_INET AF_INET6"; RestrictAddressFamilies = "AF_INET AF_INET6";
}; };
@ -97,4 +118,3 @@ with lib; {
} }
); );
} }

View file

@ -1,11 +1,15 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let
cfg = config.cloud.firezone; cfg = config.cloud.firezone;
mkImage = mkImage = { imageName, imageDigest, ... }: "${imageName}@${imageDigest}";
{ imageName, imageDigest, ... }: "${imageName}@${imageDigest}";
# If we can pullImage we can just do # If we can pullImage we can just do
# mkImage = pkgs.dockerTools.pullImage; # mkImage = pkgs.dockerTools.pullImage;
@ -48,7 +52,10 @@ in
image = images.postgresql; image = images.postgresql;
restart = "unless-stopped"; restart = "unless-stopped";
healthcheck = { healthcheck = {
test = [ "CMD-SHELL" "pg_isready -d $\${POSTGRES_DB} -U $\${POSTGRES_USER}" ]; test = [
"CMD-SHELL"
"pg_isready -d $\${POSTGRES_DB} -U $\${POSTGRES_USER}"
];
start_period = "20s"; start_period = "20s";
interval = "30s"; interval = "30s";
retries = 5; retries = 5;
@ -89,7 +96,10 @@ in
driver = "bridge"; driver = "bridge";
ipam.config = [ ipam.config = [
{ subnet = "172.25.0.0/16"; } { subnet = "172.25.0.0/16"; }
{ subnet = "2001:3990:3990::/64"; gateway = "2001:3990:3990::1"; } {
subnet = "2001:3990:3990::/64";
gateway = "2001:3990:3990::1";
}
]; ];
}; };
}; };

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let
cfg = config.cloud.gotosocial; cfg = config.cloud.gotosocial;
@ -41,13 +46,21 @@ in
# Postgres # Postgres
cloud.postgresql.databases = [ dbUser ]; cloud.postgresql.databases = [ dbUser ];
# Traefik # Traefik
cloud.traefik.hosts = { gotosocial = { inherit (cfg) host port; }; } // cloud.traefik.hosts =
(if cfg.accountDomain != cfg.host && cfg.accountDomain != "" then { {
gotosocial = { inherit (cfg) host port; };
}
// (
if cfg.accountDomain != cfg.host && cfg.accountDomain != "" then
{
gotosocial-wellknown = { gotosocial-wellknown = {
inherit (cfg) port; inherit (cfg) port;
filter = "Host(`${cfg.accountDomain}`) && (PathPrefix(`/.well-known/webfinger`) || PathPrefix(`/.well-known/nodeinfo`) || PathPrefix(`/.well-known/host-meta`))"; filter = "Host(`${cfg.accountDomain}`) && (PathPrefix(`/.well-known/webfinger`) || PathPrefix(`/.well-known/nodeinfo`) || PathPrefix(`/.well-known/host-meta`))";
}; };
} else { }); }
else
{ }
);
# The service itself # The service itself
services.gotosocial = { services.gotosocial = {
enable = true; enable = true;
@ -60,7 +73,10 @@ in
bind-address = "localhost"; bind-address = "localhost";
port = cfg.port; port = cfg.port;
# Instance # Instance
instance-languages = [ "en-ca" "vi" ]; instance-languages = [
"en-ca"
"vi"
];
# Accounts # Accounts
accounts-registration-open = false; accounts-registration-open = false;
accounts-allow-custom-css = true; accounts-allow-custom-css = true;
@ -73,15 +89,23 @@ in
web-template-base-dir = "${cfg.package}/share/gotosocial/web/template"; web-template-base-dir = "${cfg.package}/share/gotosocial/web/template";
web-asset-base-dir = "${cfg.package}/share/gotosocial/web/assets"; web-asset-base-dir = "${cfg.package}/share/gotosocial/web/assets";
# Media # Media
media-emoji-remote-max-size = 256 * 1024 /* bytes */; media-emoji-remote-max-size =
media-emoji-local-max-size = 256 * 1024 /* bytes */; 256 * 1024 # bytes
;
media-emoji-local-max-size =
256 * 1024 # bytes
;
media-remote-cache-days = 7; media-remote-cache-days = 7;
media-cleanup-from = "00:00"; media-cleanup-from = "00:00";
media-cleanup-every = "24h"; media-cleanup-every = "24h";
# OIDC # OIDC
oidc-enabled = true; oidc-enabled = true;
oidc-idp-name = "DTTH"; oidc-idp-name = "DTTH";
oidc-scopes = [ "openid" "email" "profile" ]; oidc-scopes = [
"openid"
"email"
"profile"
];
# HTTP Client # HTTP Client
http-client.block-ips = [ "11.0.0.0/24" ]; http-client.block-ips = [ "11.0.0.0/24" ];
# Advanced # Advanced
@ -92,8 +116,14 @@ in
# instance-inject-mastodon-version = true; # instance-inject-mastodon-version = true;
}; };
}; };
systemd.services.gotosocial.requires = mkAfter [ "postgresql.service" "arion-authentik.service" ]; systemd.services.gotosocial.requires = mkAfter [
systemd.services.gotosocial.after = mkAfter [ "postgresql.service" "arion-authentik.service" ]; "postgresql.service"
"arion-authentik.service"
];
systemd.services.gotosocial.after = mkAfter [
"postgresql.service"
"arion-authentik.service"
];
systemd.services.gotosocial.unitConfig = { systemd.services.gotosocial.unitConfig = {
RequiresMountsFor = [ storageLocation ]; RequiresMountsFor = [ storageLocation ];
ReadWritePaths = [ storageLocation ]; ReadWritePaths = [ storageLocation ];

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
with lib; with lib;
let let
@ -238,7 +243,12 @@ in
# MTA-STS server # MTA-STS server
services.nginx.enable = true; services.nginx.enable = true;
services.nginx.virtualHosts.maddy-mta-sts = { services.nginx.virtualHosts.maddy-mta-sts = {
listen = [{ addr = "127.0.0.1"; port = mtaStsPort; }]; listen = [
{
addr = "127.0.0.1";
port = mtaStsPort;
}
];
root = mtaStsDir; root = mtaStsDir;
}; };
@ -273,7 +283,10 @@ in
# maddy itself # maddy itself
systemd.services."${name}" = { systemd.services."${name}" = {
after = [ "network.target" "traefik-certs-dumper.service" ]; after = [
"network.target"
"traefik-certs-dumper.service"
];
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
requires = [ "postgresql.service" ]; requires = [ "postgresql.service" ];
@ -327,7 +340,6 @@ in
KillMode = "mixed"; KillMode = "mixed";
KillSignal = "SIGTERM"; KillSignal = "SIGTERM";
# Required to bind on ports lower than 1024. # Required to bind on ports lower than 1024.
AmbientCapabilities = "CAP_NET_BIND_SERVICE"; AmbientCapabilities = "CAP_NET_BIND_SERVICE";
CapabilityBoundingSet = "CAP_NET_BIND_SERVICE"; CapabilityBoundingSet = "CAP_NET_BIND_SERVICE";

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let

View file

@ -1,4 +1,9 @@
{ pkgs, lib, config, ... }: {
pkgs,
lib,
config,
...
}:
with lib; with lib;
let let
@ -9,24 +14,28 @@ let
}; };
# Copied from traefik.nix # Copied from traefik.nix
jsonValue = with types; jsonValue =
with types;
let let
valueType = nullOr valueType =
(oneOf [ nullOr (oneOf [
bool bool
int int
float float
str str
(lazyAttrsOf valueType) (lazyAttrsOf valueType)
(listOf valueType) (listOf valueType)
]) // { ])
// {
description = "JSON value"; description = "JSON value";
emptyValue.value = { }; emptyValue.value = { };
}; };
in in
valueType; valueType;
hostType = with types; submodule { hostType =
with types;
submodule {
options = { options = {
host = mkOption { host = mkOption {
type = str; type = str;
@ -52,7 +61,14 @@ let
description = "The port that the service is listening on"; description = "The port that the service is listening on";
}; };
entrypoints = mkOption { entrypoints = mkOption {
type = listOf (enum [ "http" "https" "smtp-submission" "smtp-submission-ssl" "imap" "wireguard" ]); type = listOf (enum [
"http"
"https"
"smtp-submission"
"smtp-submission-ssl"
"imap"
"wireguard"
]);
default = [ "https" ]; default = [ "https" ];
description = "The entrypoints that will serve the host"; description = "The entrypoints that will serve the host";
}; };
@ -62,7 +78,11 @@ let
description = "The middlewares to be used with the host."; description = "The middlewares to be used with the host.";
}; };
protocol = mkOption { protocol = mkOption {
type = enum [ "http" "tcp" "udp" ]; type = enum [
"http"
"tcp"
"udp"
];
default = "http"; default = "http";
description = "The protocol of the router and service"; description = "The protocol of the router and service";
}; };
@ -80,55 +100,83 @@ let
}; };
# Returns the filter given a host configuration # Returns the filter given a host configuration
filterOfHost = host: filterOfHost =
host:
let let
hostFilter = if host.protocol == "http" then "Host" else "HostSNI"; hostFilter = if host.protocol == "http" then "Host" else "HostSNI";
in in
if host.filter != null then host.filter if host.filter != null then
else if host.path == null then "${hostFilter}(`${host.host}`)" host.filter
else "${hostFilter}(`${host.host}`) && Path(`${host.path}`)"; else if host.path == null then
"${hostFilter}(`${host.host}`)"
else
"${hostFilter}(`${host.host}`) && Path(`${host.path}`)";
# Turns a host configuration into dynamic traefik configuration # Turns a host configuration into dynamic traefik configuration
hostToConfig = name: host: { hostToConfig = name: host: {
"${host.protocol}" = { "${host.protocol}" =
routers."${name}-router" = (if (host.protocol != "udp") then { {
routers."${name}-router" =
(
if (host.protocol != "udp") then
{
rule = filterOfHost host; rule = filterOfHost host;
tls = { certResolver = "le"; } tls =
// (if host.protocol == "tcp" then { passthrough = if (host ? tlsPassthrough) then host.tlsPassthrough else true; } else { }) {
certResolver = "le";
}
// (
if host.protocol == "tcp" then
{ passthrough = if (host ? tlsPassthrough) then host.tlsPassthrough else true; }
else
{ }
)
// (if host.noCloudflare then tlsNoCloudflare else { }); // (if host.noCloudflare then tlsNoCloudflare else { });
} else { }) // { }
else
{ }
)
// {
entryPoints = host.entrypoints; entryPoints = host.entrypoints;
service = "${name}-service"; service = "${name}-service";
} // ( }
// (
if host.protocol == "http" then if host.protocol == "http" then
{ middlewares = lists.imap0 (id: m: "${name}-middleware-${toString id}") host.middlewares; } { middlewares = lists.imap0 (id: m: "${name}-middleware-${toString id}") host.middlewares; }
else if host.middlewares == [ ] then else if host.middlewares == [ ] then
{ } { }
else abort "Cannot have middlewares on non-http routers" else
abort "Cannot have middlewares on non-http routers"
); );
services."${name}-service".loadBalancer.servers = [ services."${name}-service".loadBalancer.servers = [
( (
let let
localhost = localhost =
if isNull host.localHost then if isNull host.localHost then
( (if host.protocol == "http" then "localhost" else "127.0.0.1")
if host.protocol == "http" then "localhost" else
else "127.0.0.1" host.localHost;
) else host.localHost;
in in
if host.protocol == "http" then if host.protocol == "http" then
{ url = "http://${localhost}:${toString host.port}"; } { url = "http://${localhost}:${toString host.port}"; }
else { address = "${localhost}:${toString host.port}"; } else
{ address = "${localhost}:${toString host.port}"; }
) )
]; ];
} // (if (host.middlewares != [ ]) then { }
middlewares = builtins.listToAttrs (lists.imap0 // (
(id: v: { if (host.middlewares != [ ]) then
{
middlewares = builtins.listToAttrs (
lists.imap0 (id: v: {
name = "${name}-middleware-${toString id}"; name = "${name}-middleware-${toString id}";
value = v; value = v;
}) }) host.middlewares
host.middlewares); );
} else { }); }
else
{ }
);
}; };
tlsConfig = { tlsConfig = {

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let
@ -28,7 +33,8 @@ in
# Dynamic configuration # Dynamic configuration
# --------------------- # ---------------------
## Middleware ## Middleware
services.traefik.dynamicConfigOptions.http.middlewares.dashboard-auth.basicAuth.usersFile = cfg.usersFile; services.traefik.dynamicConfigOptions.http.middlewares.dashboard-auth.basicAuth.usersFile =
cfg.usersFile;
## Router ## Router
services.traefik.dynamicConfigOptions.http.routers.dashboard = { services.traefik.dynamicConfigOptions.http.routers.dashboard = {
rule = "Host(`${cfg.host}`)"; rule = "Host(`${cfg.host}`)";

View file

@ -1,19 +1,26 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let
# Copied from traefik.nix # Copied from traefik.nix
jsonValue = with types; jsonValue =
with types;
let let
valueType = nullOr valueType =
(oneOf [ nullOr (oneOf [
bool bool
int int
float float
str str
(lazyAttrsOf valueType) (lazyAttrsOf valueType)
(listOf valueType) (listOf valueType)
]) // { ])
// {
description = "JSON value"; description = "JSON value";
emptyValue.value = { }; emptyValue.value = { };
}; };
@ -41,7 +48,11 @@ let
cfg = config.cloud.traefik; cfg = config.cloud.traefik;
in in
{ {
imports = [ ./config.nix ./dashboard.nix ./certs-dumper.nix ]; imports = [
./config.nix
./dashboard.nix
./certs-dumper.nix
];
options.cloud.traefik = { options.cloud.traefik = {
cloudflareKeyFile = mkOption { cloudflareKeyFile = mkOption {
type = types.path; type = types.path;
@ -104,7 +115,12 @@ in
config.systemd.services.traefik.environment.CF_DNS_API_TOKEN_FILE = cfg.cloudflareKeyFile; config.systemd.services.traefik.environment.CF_DNS_API_TOKEN_FILE = cfg.cloudflareKeyFile;
# Set up firewall to allow traefik traffic. # Set up firewall to allow traefik traffic.
config.networking.firewall.allowedTCPPorts = [ 443 993 587 465 ]; config.networking.firewall.allowedTCPPorts = [
443
993
587
465
];
config.networking.firewall.allowedUDPPorts = [ config.networking.firewall.allowedUDPPorts = [
443 # QUIC 443 # QUIC
51820 # Wireguard 51820 # Wireguard

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
with lib; with lib;
let let
cfg = config.cloud.writefreely; cfg = config.cloud.writefreely;
@ -62,4 +67,3 @@ in
} }
); );
} }

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let
@ -6,12 +11,16 @@ let
# Modules # Modules
modules = { modules = {
adb = { config, ... }: mkIf config.common.linux.enable { adb =
{ config, ... }:
mkIf config.common.linux.enable {
services.udev.packages = with pkgs; [ android-udev-rules ]; services.udev.packages = with pkgs; [ android-udev-rules ];
programs.adb.enable = true; programs.adb.enable = true;
users.users.${config.common.linux.username}.extraGroups = [ "adbusers" ]; users.users.${config.common.linux.username}.extraGroups = [ "adbusers" ];
}; };
ios = { config, pkgs, ... }: mkIf config.common.linux.enable { ios =
{ config, pkgs, ... }:
mkIf config.common.linux.enable {
services.usbmuxd.enable = true; services.usbmuxd.enable = true;
services.usbmuxd.package = pkgs.usbmuxd2; services.usbmuxd.package = pkgs.usbmuxd2;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
@ -26,17 +35,27 @@ let
}; };
}; };
graphics = { config, pkgs, ... }: { graphics =
{ config, pkgs, ... }:
{
hardware.graphics.enable = true; hardware.graphics.enable = true;
hardware.graphics.enable32Bit = true; hardware.graphics.enable32Bit = true;
# Monitor backlight # Monitor backlight
hardware.i2c.enable = true; hardware.i2c.enable = true;
services.ddccontrol.enable = true; services.ddccontrol.enable = true;
environment.systemPackages = [ pkgs.luminance pkgs.ddcutil ]; environment.systemPackages = [
pkgs.luminance
pkgs.ddcutil
];
}; };
accounts = { pkgs, ... }: mkIf (config.common.linux.enable && !pkgs.stdenv.isAarch64) { accounts =
environment.systemPackages = [ pkgs.glib (pkgs.gnome-control-center or pkgs.gnome.gnome-control-center) ]; { pkgs, ... }:
mkIf (config.common.linux.enable && !pkgs.stdenv.isAarch64) {
environment.systemPackages = [
pkgs.glib
(pkgs.gnome-control-center or pkgs.gnome.gnome-control-center)
];
services.accounts-daemon.enable = true; services.accounts-daemon.enable = true;
services.gnome.gnome-online-accounts.enable = true; services.gnome.gnome-online-accounts.enable = true;
# programs.evolution.enable = true; # programs.evolution.enable = true;
@ -45,7 +64,9 @@ let
# services.gnome.evolution-data-server.plugins = with pkgs; [ evolution-ews ]; # services.gnome.evolution-data-server.plugins = with pkgs; [ evolution-ews ];
}; };
wlr = { lib, config, ... }: mkIf config.common.linux.enable { wlr =
{ lib, config, ... }:
mkIf config.common.linux.enable {
# swaync disable notifications on screencast # swaync disable notifications on screencast
xdg.portal.wlr.settings.screencast = { xdg.portal.wlr.settings.screencast = {
exec_before = ''which swaync-client && swaync-client --inhibitor-add "xdg-desktop-portal-wlr" || true''; exec_before = ''which swaync-client && swaync-client --inhibitor-add "xdg-desktop-portal-wlr" || true'';
@ -60,12 +81,16 @@ let
services.gnome.gnome-keyring.enable = lib.mkForce false; services.gnome.gnome-keyring.enable = lib.mkForce false;
}; };
logitech = { pkgs, ... }: mkIf cfg.enable { logitech =
{ pkgs, ... }:
mkIf cfg.enable {
services.ratbagd.enable = true; services.ratbagd.enable = true;
environment.systemPackages = with pkgs; [ piper ]; environment.systemPackages = with pkgs; [ piper ];
}; };
kwallet = { pkgs, lib, ... }: mkIf cfg.enable { kwallet =
{ pkgs, lib, ... }:
mkIf cfg.enable {
environment.systemPackages = [ pkgs.kdePackages.kwallet ]; environment.systemPackages = [ pkgs.kdePackages.kwallet ];
services.dbus.packages = [ pkgs.kdePackages.kwallet ]; services.dbus.packages = [ pkgs.kdePackages.kwallet ];
xdg.portal = { xdg.portal = {
@ -73,7 +98,9 @@ let
}; };
}; };
virtualisation = { pkgs, ... }: mkIf cfg.enable { virtualisation =
{ pkgs, ... }:
mkIf cfg.enable {
virtualisation.podman = { virtualisation.podman = {
enable = true; enable = true;
extraPackages = [ pkgs.slirp4netns ]; extraPackages = [ pkgs.slirp4netns ];
@ -88,7 +115,9 @@ let
}; };
}; };
rt-audio = { pkgs, ... }: mkIf cfg.enable { rt-audio =
{ pkgs, ... }:
mkIf cfg.enable {
services.pipewire.lowLatency = { services.pipewire.lowLatency = {
# enable this module # enable this module
enable = true; enable = true;
@ -155,10 +184,14 @@ in
dnsServers = mkOption { dnsServers = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
description = "DNS server list"; description = "DNS server list";
default = [ "1.1.1.1" "2606:4700:4700:1111" ]; default = [
"1.1.1.1"
"2606:4700:4700:1111"
];
}; };
networks = mkOption { networks = mkOption {
type = types.attrsOf (types.submodule { type = types.attrsOf (
types.submodule {
options.match = mkOption { options.match = mkOption {
type = types.str; type = types.str;
description = "The interface name to match"; description = "The interface name to match";
@ -168,10 +201,13 @@ in
description = "Require this interface to be connected for network-online.target"; description = "Require this interface to be connected for network-online.target";
default = false; default = false;
}; };
}); }
);
description = "Network configuration"; description = "Network configuration";
default = { default = {
default = { match = "*"; }; default = {
match = "*";
};
}; };
}; };
}; };
@ -196,8 +232,7 @@ in
}; };
boot.initrd.systemd.enable = builtins.length (builtins.attrNames (cfg.luksDevices)) > 0; boot.initrd.systemd.enable = builtins.length (builtins.attrNames (cfg.luksDevices)) > 0;
# LUKS devices # LUKS devices
boot.initrd.luks.devices = builtins.mapAttrs boot.initrd.luks.devices = builtins.mapAttrs (name: path: {
(name: path: {
device = path; device = path;
preLVM = true; preLVM = true;
allowDiscards = true; allowDiscards = true;
@ -206,8 +241,7 @@ in
"tpm2-device=auto" "tpm2-device=auto"
"fido2-device=auto" "fido2-device=auto"
]; ];
}) }) cfg.luksDevices;
cfg.luksDevices;
## Hardware-related ## Hardware-related
@ -251,7 +285,10 @@ in
]; ];
shell = pkgs.fish; shell = pkgs.fish;
}; };
nix.settings.trusted-users = [ "root" cfg.username ]; nix.settings.trusted-users = [
"root"
cfg.username
];
## Network configuration ## Network configuration
systemd.network.enable = true; systemd.network.enable = true;
@ -262,13 +299,11 @@ in
networking.hostName = cfg.networking.hostname; networking.hostName = cfg.networking.hostname;
networking.wireless.iwd.enable = true; networking.wireless.iwd.enable = true;
networking.wireless.iwd.settings.General.EnableNetworkConfiguration = true; networking.wireless.iwd.settings.General.EnableNetworkConfiguration = true;
systemd.network.networks = builtins.mapAttrs systemd.network.networks = builtins.mapAttrs (name: cfg: {
(name: cfg: {
matchConfig.Name = cfg.match; matchConfig.Name = cfg.match;
networkConfig.DHCP = "yes"; networkConfig.DHCP = "yes";
linkConfig.RequiredForOnline = if cfg.isRequired then "yes" else "no"; linkConfig.RequiredForOnline = if cfg.isRequired then "yes" else "no";
}) }) cfg.networking.networks;
cfg.networking.networks;
# Leave DNS to systemd-resolved # Leave DNS to systemd-resolved
services.resolved.enable = true; services.resolved.enable = true;
services.resolved.domains = cfg.networking.dnsServers; services.resolved.domains = cfg.networking.dnsServers;
@ -285,19 +320,26 @@ in
console.keyMap = "jp106"; # Console key layout console.keyMap = "jp106"; # Console key layout
i18n.defaultLocale = "ja_JP.UTF-8"; i18n.defaultLocale = "ja_JP.UTF-8";
# Input methods (only fcitx5 works reliably on Wayland) # Input methods (only fcitx5 works reliably on Wayland)
i18n.inputMethod = { i18n.inputMethod =
{
fcitx5.waylandFrontend = true; fcitx5.waylandFrontend = true;
fcitx5.addons = with pkgs; [ fcitx5.addons = with pkgs; [
fcitx5-mozc fcitx5-mozc
fcitx5-unikey fcitx5-unikey
fcitx5-gtk fcitx5-gtk
]; ];
} // (if config.system.nixos.release == "24.05" then { }
// (
if config.system.nixos.release == "24.05" then
{
enabled = "fcitx5"; enabled = "fcitx5";
} else { }
else
{
enable = true; enable = true;
type = "fcitx5"; type = "fcitx5";
}); }
);
# Default packages # Default packages
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
@ -335,7 +377,10 @@ in
programs.gamescope = { programs.gamescope = {
enable = true; enable = true;
# capSysNice = true; # https://github.com/NixOS/nixpkgs/issues/351516 # capSysNice = true; # https://github.com/NixOS/nixpkgs/issues/351516
args = [ "--adaptive-sync" "--rt" ]; args = [
"--adaptive-sync"
"--rt"
];
}; };
## Services ## Services
@ -353,11 +398,22 @@ in
wlr.enable = true; wlr.enable = true;
xdgOpenUsePortal = true; xdgOpenUsePortal = true;
# gtk portal needed to make gtk apps happy # gtk portal needed to make gtk apps happy
extraPortals = [ pkgs.kdePackages.xdg-desktop-portal-kde pkgs.xdg-desktop-portal-gtk ]; extraPortals = [
pkgs.kdePackages.xdg-desktop-portal-kde
pkgs.xdg-desktop-portal-gtk
];
config.sway.default = [ "wlr" "kde" "kwallet" ]; config.sway.default = [
"wlr"
"kde"
"kwallet"
];
config.niri = { config.niri = {
default = [ "kde" "gnome" "gtk" ]; default = [
"kde"
"gnome"
"gtk"
];
# "org.freedesktop.impl.portal.Access" = "gtk"; # "org.freedesktop.impl.portal.Access" = "gtk";
# "org.freedesktop.impl.portal.Notification" = "gtk"; # "org.freedesktop.impl.portal.Notification" = "gtk";
"org.freedesktop.impl.portal.ScreenCast" = "gnome"; "org.freedesktop.impl.portal.ScreenCast" = "gnome";

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
with lib; with lib;
let let
@ -36,8 +41,11 @@ in
}; };
}; };
config = mkIf cfg.enable (builtins.seq config = mkIf cfg.enable (
(mkIf (isNull cfg.rsaPrivateKey && isNull cfg.ed25519PrivateKey) (builtins.abort "one of the keys must be defined")) builtins.seq
(mkIf (isNull cfg.rsaPrivateKey && isNull cfg.ed25519PrivateKey) (
builtins.abort "one of the keys must be defined"
))
( (
let let
networkName = "my-tinc"; networkName = "my-tinc";
@ -73,17 +81,31 @@ in
# simple interface setup # simple interface setup
# ---------------------- # ----------------------
networking.interfaces."tinc.${networkName}".ipv4.addresses = [{ address = myMeshIp; prefixLength = 24; }]; networking.interfaces."tinc.${networkName}".ipv4.addresses = [
{
address = myMeshIp;
prefixLength = 24;
}
];
# firewall # firewall
networking.firewall.allowedUDPPorts = [ 655 ]; networking.firewall.allowedUDPPorts = [ 655 ];
networking.firewall.allowedTCPPorts = [ 655 ]; networking.firewall.allowedTCPPorts = [ 655 ];
networking.firewall.interfaces."tinc.${networkName}" = { networking.firewall.interfaces."tinc.${networkName}" = {
allowedUDPPortRanges = [{ from = 0; to = 65535; }]; allowedUDPPortRanges = [
allowedTCPPortRanges = [{ from = 0; to = 65535; }]; {
from = 0;
to = 65535;
}
];
allowedTCPPortRanges = [
{
from = 0;
to = 65535;
}
];
}; };
# configure tinc service # configure tinc service
# ---------------------- # ----------------------
services.tinc.networks."${networkName}" = { services.tinc.networks."${networkName}" = {

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
with lib; with lib;
let let
@ -6,30 +11,34 @@ let
cfg = config.services.my-tinc; cfg = config.services.my-tinc;
mapAttrs = f: attrs: builtins.listToAttrs ( mapAttrs =
map (name: { inherit name; value = f name (builtins.getAttr name attrs); }) (builtins.attrNames attrs) f: attrs:
builtins.listToAttrs (
map (name: {
inherit name;
value = f name (builtins.getAttr name attrs);
}) (builtins.attrNames attrs)
); );
in in
{ {
config = mkIf cfg.enable { config = mkIf cfg.enable {
# All hosts we know of # All hosts we know of
services.tinc.networks.my-tinc.hostSettings = mapAttrs services.tinc.networks.my-tinc.hostSettings = mapAttrs (name: host: {
(name: host: {
addresses = if (host ? address) then [ { address = host.address; } ] else [ ]; addresses = if (host ? address) then [ { address = host.address; } ] else [ ];
subnets = [ { address = host.subnetAddr; } ]; subnets = [ { address = host.subnetAddr; } ];
rsaPublicKey = mkIf (host ? "rsaPublicKey") host.rsaPublicKey; rsaPublicKey = mkIf (host ? "rsaPublicKey") host.rsaPublicKey;
settings.Ed25519PublicKey = mkIf (host ? "ed25519PublicKey") host.ed25519PublicKey; settings.Ed25519PublicKey = mkIf (host ? "ed25519PublicKey") host.ed25519PublicKey;
}) }) hosts;
hosts;
# Add all of them to host # Add all of them to host
nki.services.edns = { nki.services.edns = {
enable = true; enable = true;
cloaking-rules = cloaking-rules = (
(lib.attrsets.mapAttrs' lib.attrsets.mapAttrs' (name: host: {
(name: host: { name = "${name}.tinc"; value = host.subnetAddr; }) name = "${name}.tinc";
hosts) value = host.subnetAddr;
; }) hosts
);
}; };
}; };
} }

View file

@ -1,4 +1,9 @@
{ pkgs, lib, config, ... }: {
pkgs,
lib,
config,
...
}:
with lib; with lib;
let let
@ -11,8 +16,11 @@ in
{ {
imports = [ ./mounting.nix ]; imports = [ ./mounting.nix ];
# Fonts # Fonts
config.fonts = { config.fonts =
packages = with pkgs; mkForce [ {
packages =
with pkgs;
mkForce [
noto-fonts-emoji-blob-bin noto-fonts-emoji-blob-bin
ibm-plex ibm-plex
nerd-fonts nerd-fonts
@ -23,14 +31,33 @@ in
font-awesome font-awesome
hack-font # for Plasma hack-font # for Plasma
]; ];
} // (if pkgs.stdenv.isLinux then { }
// (
if pkgs.stdenv.isLinux then
{
enableDefaultPackages = false; enableDefaultPackages = false;
fontconfig = { fontconfig = {
defaultFonts = { defaultFonts = {
emoji = lib.mkBefore [ "Blobmoji" ]; emoji = lib.mkBefore [ "Blobmoji" ];
serif = lib.mkBefore [ "IBM Plex Serif" "IBM Plex Sans JP" "IBM Plex Sans KR" "Blobmoji" ]; serif = lib.mkBefore [
sansSerif = lib.mkBefore [ "IBM Plex Sans" "IBM Plex Sans JP" "IBM Plex Sans KR" "Blobmoji" ]; "IBM Plex Serif"
monospace = lib.mkBefore [ "IBM Plex Mono" "Font Awesome 6 Free" "Symbols Nerd Font" "Blobmoji" "IBM Plex Sans JP" ]; "IBM Plex Sans JP"
"IBM Plex Sans KR"
"Blobmoji"
];
sansSerif = lib.mkBefore [
"IBM Plex Sans"
"IBM Plex Sans JP"
"IBM Plex Sans KR"
"Blobmoji"
];
monospace = lib.mkBefore [
"IBM Plex Mono"
"Font Awesome 6 Free"
"Symbols Nerd Font"
"Blobmoji"
"IBM Plex Sans JP"
];
}; };
localConf = '' localConf = ''
<?xml version="1.0"?> <?xml version="1.0"?>
@ -49,8 +76,16 @@ in
''; '';
}; };
fontDir.enable = true; fontDir.enable = true;
} else { }) // (if pkgs.stdenv.isDarwin then {
fontDir.enable = true;
} else { });
} }
else
{ }
)
// (
if pkgs.stdenv.isDarwin then
{
fontDir.enable = true;
}
else
{ }
);
}

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
lib.mkIf pkgs.stdenv.isLinux { lib.mkIf pkgs.stdenv.isLinux {
system.fsPackages = [ pkgs.bindfs ]; system.fsPackages = [ pkgs.bindfs ];
fileSystems = fileSystems =
@ -6,7 +11,11 @@ lib.mkIf pkgs.stdenv.isLinux {
mkRoSymBind = path: { mkRoSymBind = path: {
device = path; device = path;
fsType = "fuse.bindfs"; fsType = "fuse.bindfs";
options = [ "ro" "resolve-symlinks" "x-gvfs-hide" ]; options = [
"ro"
"resolve-symlinks"
"x-gvfs-hide"
];
}; };
aggregatedIcons = pkgs.buildEnv { aggregatedIcons = pkgs.buildEnv {
name = "system-icons"; name = "system-icons";

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
with lib; with lib;
let let

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let
@ -34,7 +39,10 @@ in
# Sources # Sources
sources.public_resolvers = { sources.public_resolvers = {
urls = [ "https://raw.githubusercontent.com/DNSCrypt/dnscrypt-resolvers/master/v3/public-resolvers.md" "https://download.dnscrypt.info/resolvers-list/v3/public-resolvers.md" ]; urls = [
"https://raw.githubusercontent.com/DNSCrypt/dnscrypt-resolvers/master/v3/public-resolvers.md"
"https://download.dnscrypt.info/resolvers-list/v3/public-resolvers.md"
];
cache_file = "/var/lib/dnscrypt-proxy/public_resolvers.md"; cache_file = "/var/lib/dnscrypt-proxy/public_resolvers.md";
minisign_key = "RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3"; minisign_key = "RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3";
}; };
@ -44,14 +52,22 @@ in
# Anonymized DNS # Anonymized DNS
anonymized_dns.routes = [ anonymized_dns.routes = [
{ server_name = "*"; via = [ "anon-plan9-dns" "anon-v.dnscrypt.up-ipv4" ]; } {
server_name = "*";
via = [
"anon-plan9-dns"
"anon-v.dnscrypt.up-ipv4"
];
}
]; ];
anonymized_dns.skip_incompatible = true; anonymized_dns.skip_incompatible = true;
# Cloaking rules # Cloaking rules
cloaking_rules = pkgs.writeText "cloaking_rules.txt" (lib.strings.concatStringsSep cloaking_rules = pkgs.writeText "cloaking_rules.txt" (
"\n" lib.strings.concatStringsSep "\n" (
(lib.attrsets.mapAttrsToList (name: ip: "${name} ${ip}") cfg.cloaking-rules)); lib.attrsets.mapAttrsToList (name: ip: "${name} ${ip}") cfg.cloaking-rules
)
);
}; };
}; };
}; };

View file

@ -40,20 +40,24 @@ in
in in
{ {
nix.distributedBuilds = true; nix.distributedBuilds = true;
nix.buildMachines = lib.mapAttrsToList nix.buildMachines = lib.mapAttrsToList (
(name: host: { name: host:
{
hostName = host.host; hostName = host.host;
sshUser = build-user; sshUser = build-user;
sshKey = cfg.privateKeyFile; sshKey = cfg.privateKeyFile;
} // host.builder) }
otherBuilders; // host.builder
) otherBuilders;
users = mkIf (isBuilder host) { users = mkIf (isBuilder host) {
users.${build-user} = { users.${build-user} = {
description = "Nix build farm user"; description = "Nix build farm user";
group = build-user; group = build-user;
isNormalUser = true; isNormalUser = true;
openssh.authorizedKeys.keys = lib.mapAttrsToList (_: host: ''from="${cfg.ipAddrs}" ${host.pubKey}'') otherHosts; openssh.authorizedKeys.keys = lib.mapAttrsToList (
_: host: ''from="${cfg.ipAddrs}" ${host.pubKey}''
) otherHosts;
}; };
groups.${build-user} = { }; groups.${build-user} = { };
}; };
@ -62,5 +66,3 @@ in
} }
); );
} }

View file

@ -10,10 +10,18 @@
builder = { builder = {
publicHostKey = "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUhiVTh2NlNBa0kyOTBCc1QzVG1IRVVJQWdXcVFyNm9jRmpjakRRczRoT2ggcm9vdEBrYWdhbWlQQwo="; publicHostKey = "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUhiVTh2NlNBa0kyOTBCc1QzVG1IRVVJQWdXcVFyNm9jRmpjakRRczRoT2ggcm9vdEBrYWdhbWlQQwo=";
systems = [ "x86_64-linux" "aarch64-linux" ]; systems = [
"x86_64-linux"
"aarch64-linux"
];
maxJobs = 16; maxJobs = 16;
speedFactor = 2; speedFactor = 2;
supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; supportedFeatures = [
"nixos-test"
"benchmark"
"big-parallel"
"kvm"
];
}; };
}; };
@ -28,10 +36,18 @@
builder = { builder = {
publicHostKey = "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUdOUlBCVFRkNTVVMXY1U1Jac0FjYVdhS3JGZTY0ZjIxOVViODVTQ2NWd28gcm9vdEBua2ktZnJhbWV3b3JrCg=="; publicHostKey = "c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUdOUlBCVFRkNTVVMXY1U1Jac0FjYVdhS3JGZTY0ZjIxOVViODVTQ2NWd28gcm9vdEBua2ktZnJhbWV3b3JrCg==";
systems = [ "x86_64-linux" "aarch64-linux" ]; systems = [
"x86_64-linux"
"aarch64-linux"
];
maxJobs = 16; maxJobs = 16;
speedFactor = 3; speedFactor = 3;
supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; supportedFeatures = [
"nixos-test"
"benchmark"
"big-parallel"
"kvm"
];
}; };
}; };
} }

View file

@ -1,6 +1,18 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
with { inherit (lib) mkEnableOption mkOption types mkIf; }; with {
inherit (lib)
mkEnableOption
mkOption
types
mkIf
;
};
let let
cfg = config.nki.services.nix-cache; cfg = config.nki.services.nix-cache;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
with lib; with lib;
let let
cfg = config.services.swaylock; cfg = config.services.swaylock;

View file

@ -2,11 +2,15 @@
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
{ {
imports = imports = [
[
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
# Fonts # Fonts
@ -21,7 +25,9 @@
common.linux.sops.enable = true; common.linux.sops.enable = true;
common.linux.sops.file = ./secrets.yaml; common.linux.sops.file = ./secrets.yaml;
sops.secrets."nix-build-farm/private-key" = { mode = "0400"; }; sops.secrets."nix-build-farm/private-key" = {
mode = "0400";
};
services.nix-build-farm.hostname = "framework"; services.nix-build-farm.hostname = "framework";
services.nix-build-farm.privateKeyFile = config.sops.secrets."nix-build-farm/private-key".path; services.nix-build-farm.privateKeyFile = config.sops.secrets."nix-build-farm/private-key".path;
@ -94,7 +100,6 @@
bindPort = 6565; bindPort = 6565;
}; };
# Secrets # Secrets
# sops.defaultSopsFile = ./secrets.yaml; # sops.defaultSopsFile = ./secrets.yaml;
# sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ]; # sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
@ -129,4 +134,3 @@
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.05"; # Did you read the comment? system.stateVersion = "22.05"; # Did you read the comment?
} }

View file

@ -1,15 +1,26 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: {
config,
lib,
pkgs,
modulesPath,
...
}:
{ {
imports = imports = [
[
(modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
]; ];
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "sd_mod" ]; boot.initrd.availableKernelModules = [
"nvme"
"xhci_pci"
"thunderbolt"
"usb_storage"
"sd_mod"
];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ]; boot.kernelModules = [ "kvm-amd" ];
boot.kernelParams = [ boot.kernelParams = [
@ -18,11 +29,13 @@
"resume_offset=5776640" # btrfs inspect-internal map-swapfile -r /var/swapfile "resume_offset=5776640" # btrfs inspect-internal map-swapfile -r /var/swapfile
]; ];
fileSystems."/" = fileSystems."/" = {
{
device = "/dev/disk/by-uuid/fa8aaf51-b99f-4fb4-9230-8c0957d8af3f"; device = "/dev/disk/by-uuid/fa8aaf51-b99f-4fb4-9230-8c0957d8af3f";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=root" "compress=zstd" ]; options = [
"subvol=root"
"compress=zstd"
];
}; };
services.btrfs.autoScrub = { services.btrfs.autoScrub = {
enable = true; enable = true;
@ -31,28 +44,35 @@
common.linux.luksDevices."cryptroot" = "/dev/disk/by-uuid/94226aae-6d1c-401a-bfad-3aa5f371a365"; common.linux.luksDevices."cryptroot" = "/dev/disk/by-uuid/94226aae-6d1c-401a-bfad-3aa5f371a365";
fileSystems."/home" = fileSystems."/home" = {
{
device = "/dev/disk/by-uuid/fa8aaf51-b99f-4fb4-9230-8c0957d8af3f"; device = "/dev/disk/by-uuid/fa8aaf51-b99f-4fb4-9230-8c0957d8af3f";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=home" "compress=zstd" ]; options = [
"subvol=home"
"compress=zstd"
];
}; };
fileSystems."/nix" = fileSystems."/nix" = {
{
device = "/dev/disk/by-uuid/fa8aaf51-b99f-4fb4-9230-8c0957d8af3f"; device = "/dev/disk/by-uuid/fa8aaf51-b99f-4fb4-9230-8c0957d8af3f";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=nix" "compress=zstd" ]; options = [
"subvol=nix"
"compress=zstd"
];
}; };
fileSystems."/boot" = fileSystems."/boot" = {
{
device = "/dev/disk/by-uuid/6A0E-4D23"; device = "/dev/disk/by-uuid/6A0E-4D23";
fsType = "vfat"; fsType = "vfat";
}; };
swapDevices = [ swapDevices = [
{ device = "/var/swapfile"; size = 32 * 1024; priority = 10; } {
device = "/var/swapfile";
size = 32 * 1024;
priority = 10;
}
]; ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking

View file

@ -1,4 +1,5 @@
{ pkgs, lib, ... }: { { pkgs, lib, ... }:
{
environment.systemPackages = with pkgs; [ iw ]; environment.systemPackages = with pkgs; [ iw ];
# Disable power_save on boot # Disable power_save on boot
services.udev.packages = [ services.udev.packages = [

View file

@ -1,4 +1,10 @@
{ config, pkgs, lib, ... }: { {
config,
pkgs,
lib,
...
}:
{
environment.etc = { environment.etc = {
"wireplumber/wireplumber.conf.d/51-sdac.conf".source = ./sdac.conf.json; "wireplumber/wireplumber.conf.d/51-sdac.conf".source = ./sdac.conf.json;
}; };

View file

@ -2,11 +2,18 @@
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ lib, config, pkgs, ... }: {
lib,
config,
pkgs,
...
}:
with lib; with lib;
let let
openrazer = { pkgs, ... }: { openrazer =
{ pkgs, ... }:
{
# Razer stuff # Razer stuff
hardware.openrazer = { hardware.openrazer = {
enable = true; enable = true;
@ -16,8 +23,7 @@ let
}; };
in in
{ {
imports = imports = [
[
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
# Fonts # Fonts
@ -43,19 +49,24 @@ in
common.linux.sops.file = ./secrets.yaml; common.linux.sops.file = ./secrets.yaml;
# Nix cache server # Nix cache server
sops.secrets."nix-cache/private-key" = { owner = "harmonia"; group = "harmonia"; mode = "0600"; }; sops.secrets."nix-cache/private-key" = {
owner = "harmonia";
group = "harmonia";
mode = "0600";
};
nki.services.nix-cache = { nki.services.nix-cache = {
enableServer = true; enableServer = true;
privateKeyFile = config.sops.secrets."nix-cache/private-key".path; privateKeyFile = config.sops.secrets."nix-cache/private-key".path;
}; };
sops.secrets."nix-build-farm/private-key" = { mode = "0400"; }; sops.secrets."nix-build-farm/private-key" = {
mode = "0400";
};
services.nix-build-farm.hostname = "home"; services.nix-build-farm.hostname = "home";
services.nix-build-farm.privateKeyFile = config.sops.secrets."nix-build-farm/private-key".path; services.nix-build-farm.privateKeyFile = config.sops.secrets."nix-build-farm/private-key".path;
# Networking # Networking
common.linux.networking = common.linux.networking = {
{
hostname = "kagamiPC"; # Define your hostname. hostname = "kagamiPC"; # Define your hostname.
networks = { networks = {
"10-wired" = { "10-wired" = {
@ -70,8 +81,16 @@ in
nki.services.edns.ipv6 = true; nki.services.edns.ipv6 = true;
## DTTH Wireguard ## DTTH Wireguard
# #
sops.secrets."dtth-wg/private-key" = { owner = "root"; group = "systemd-network"; mode = "0640"; }; sops.secrets."dtth-wg/private-key" = {
sops.secrets."dtth-wg/preshared-key" = { owner = "root"; group = "systemd-network"; mode = "0640"; }; owner = "root";
group = "systemd-network";
mode = "0640";
};
sops.secrets."dtth-wg/preshared-key" = {
owner = "root";
group = "systemd-network";
mode = "0640";
};
systemd.network.netdevs."10-dtth-wg" = { systemd.network.netdevs."10-dtth-wg" = {
netdevConfig = { netdevConfig = {
Kind = "wireguard"; Kind = "wireguard";
@ -81,20 +100,31 @@ in
wireguardConfig = { wireguardConfig = {
PrivateKeyFile = config.sops.secrets."dtth-wg/private-key".path; PrivateKeyFile = config.sops.secrets."dtth-wg/private-key".path;
}; };
wireguardPeers = [{ wireguardPeers = [
{
PublicKey = "+7iI4jwmM1Qr+/DKB1Hv8JgFkGu7lSV0PAoo+O5d3yQ="; PublicKey = "+7iI4jwmM1Qr+/DKB1Hv8JgFkGu7lSV0PAoo+O5d3yQ=";
PresharedKeyFile = config.sops.secrets."dtth-wg/preshared-key".path; PresharedKeyFile = config.sops.secrets."dtth-wg/preshared-key".path;
AllowedIPs = [ "100.64.0.0/10" "fd00::/106" ]; AllowedIPs = [
"100.64.0.0/10"
"fd00::/106"
];
Endpoint = "vpn.dtth.ch:51820"; Endpoint = "vpn.dtth.ch:51820";
PersistentKeepalive = 25; PersistentKeepalive = 25;
}]; }
];
}; };
systemd.network.networks."dtth-wg" = { systemd.network.networks."dtth-wg" = {
matchConfig.Name = "dtth-wg"; matchConfig.Name = "dtth-wg";
address = [ "100.73.146.80/32" "fd00::33:105b/128" ]; address = [
"100.73.146.80/32"
"fd00::33:105b/128"
];
DHCP = "no"; DHCP = "no";
routes = [ routes = [
{ Destination = "100.64.0.0/10"; Scope = "link"; } {
Destination = "100.64.0.0/10";
Scope = "link";
}
{ Destination = "fd00::/106"; } { Destination = "fd00::/106"; }
]; ];
}; };
@ -117,7 +147,11 @@ in
ntfsMount = path: { ntfsMount = path: {
device = path; device = path;
fsType = "ntfs"; fsType = "ntfs";
options = [ "rw" "uid=${toString config.users.users.nki.uid}" "nofail" ]; options = [
"rw"
"uid=${toString config.users.users.nki.uid}"
"nofail"
];
}; };
in in
{ {
@ -149,7 +183,6 @@ in
bindPort = 6565; bindPort = 6565;
}; };
# Music server # Music server
services.navidrome.enable = true; services.navidrome.enable = true;
services.navidrome.settings = { services.navidrome.settings = {
@ -157,7 +190,10 @@ in
MusicFolder = "/mnt/Stuff/Music"; MusicFolder = "/mnt/Stuff/Music";
}; };
systemd.services.navidrome.serviceConfig.BindReadOnlyPaths = lib.mkAfter [ "/etc" ]; systemd.services.navidrome.serviceConfig.BindReadOnlyPaths = lib.mkAfter [ "/etc" ];
networking.firewall.allowedTCPPorts = [ 4533 8000 ]; networking.firewall.allowedTCPPorts = [
4533
8000
];
# Printers # Printers
services.printing.enable = true; services.printing.enable = true;
@ -201,4 +237,3 @@ in
virtualisation.spiceUSBRedirection.enable = true; virtualisation.spiceUSBRedirection.enable = true;
} }

View file

@ -1,34 +1,46 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: {
config,
lib,
pkgs,
modulesPath,
...
}:
{ {
imports = imports = [
[
(modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
./audio ./audio
]; ];
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ]; boot.initrd.availableKernelModules = [
boot.initrd.kernelModules = [ "dm-snapshot" "amdgpu" ]; "nvme"
"xhci_pci"
"ahci"
"usbhid"
"usb_storage"
"sd_mod"
];
boot.initrd.kernelModules = [
"dm-snapshot"
"amdgpu"
];
boot.kernelModules = [ "kvm-amd" ]; boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" = {
{
device = "/dev/disk/by-uuid/32a74827-4624-43ef-b066-b52e1f11793d"; device = "/dev/disk/by-uuid/32a74827-4624-43ef-b066-b52e1f11793d";
fsType = "ext4"; fsType = "ext4";
}; };
fileSystems."/home/nki/Projects" = fileSystems."/home/nki/Projects" = {
{
device = "/dev/disk/by-uuid/025cb533-e21b-47f2-b7d5-322b7b95b831"; device = "/dev/disk/by-uuid/025cb533-e21b-47f2-b7d5-322b7b95b831";
fsType = "btrfs"; fsType = "btrfs";
options = [ "compress=zstd" ]; options = [ "compress=zstd" ];
}; };
fileSystems."/boot" = fileSystems."/boot" = {
{
device = "/dev/disk/by-uuid/549C-7877"; device = "/dev/disk/by-uuid/549C-7877";
fsType = "vfat"; fsType = "vfat";
}; };
@ -36,7 +48,10 @@
fileSystems."/mnt/steam" = { fileSystems."/mnt/steam" = {
device = "/dev/disk/by-uuid/d1db9f65-6add-4714-b9d7-16e16f687396"; device = "/dev/disk/by-uuid/d1db9f65-6add-4714-b9d7-16e16f687396";
fsType = "btrfs"; fsType = "btrfs";
options = [ "compress=zstd" "subvol=steam" ]; options = [
"compress=zstd"
"subvol=steam"
];
encrypted = { encrypted = {
enable = true; enable = true;
label = "encdata"; label = "encdata";
@ -45,8 +60,7 @@
}; };
}; };
swapDevices = swapDevices = [ { device = "/dev/disk/by-uuid/561f6441-1915-4059-a5e1-76a449b0c9bf"; } ];
[{ device = "/dev/disk/by-uuid/561f6441-1915-4059-a5e1-76a449b0c9bf"; }];
# bluetooth usb # bluetooth usb
hardware.firmware = [ pkgs.rtl8761b-firmware ]; hardware.firmware = [ pkgs.rtl8761b-firmware ];

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
user = "peertube-runner-nodejs"; user = "peertube-runner-nodejs";
instance = "systemd-instance"; instance = "systemd-instance";
@ -27,8 +32,8 @@ in
runnerName = "kagamipc" runnerName = "kagamipc"
''; '';
environment.etc."${user}/${instance}/config.toml".source = config.sops.templates."peertube-config.toml".path; environment.etc."${user}/${instance}/config.toml".source =
config.sops.templates."peertube-config.toml".path;
systemd.services.peertube-runner = { systemd.services.peertube-runner = {
description = "PeerTube runner daemon"; description = "PeerTube runner daemon";
@ -36,8 +41,7 @@ in
after = [ "network.target" ]; after = [ "network.target" ];
requires = [ ]; requires = [ ];
serviceConfig = serviceConfig = {
{
ExecStart = "${lib.getExe' pkgs.peertube.runner "peertube-runner"} server --id ${instance}"; ExecStart = "${lib.getExe' pkgs.peertube.runner "peertube-runner"} server --id ${instance}";
User = user; User = user;
RuntimeDirectory = user; RuntimeDirectory = user;
@ -61,7 +65,9 @@ in
XDG_STATE_HOME = "/var/lib"; XDG_STATE_HOME = "/var/lib";
}; };
path = with pkgs; [ nodejs ffmpeg ]; path = with pkgs; [
nodejs
ffmpeg
];
}; };
} }

View file

@ -1,4 +1,10 @@
{ pkgs, config, lib, ... }: { {
pkgs,
config,
lib,
...
}:
{
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
@ -88,13 +94,19 @@
services.my-tinc.rsaPrivateKey = config.sops.secrets."tinc/rsa-private-key".path; services.my-tinc.rsaPrivateKey = config.sops.secrets."tinc/rsa-private-key".path;
services.my-tinc.ed25519PrivateKey = config.sops.secrets."tinc/ed25519-private-key".path; services.my-tinc.ed25519PrivateKey = config.sops.secrets."tinc/ed25519-private-key".path;
sops.secrets."nix-build-farm/private-key" = { mode = "0400"; }; sops.secrets."nix-build-farm/private-key" = {
mode = "0400";
};
services.nix-build-farm.hostname = "home"; services.nix-build-farm.hostname = "home";
services.nix-build-farm.privateKeyFile = config.sops.secrets."nix-build-farm/private-key".path; services.nix-build-farm.privateKeyFile = config.sops.secrets."nix-build-farm/private-key".path;
# Set up traefik # Set up traefik
sops.secrets.cloudflare-dns-api-token = { owner = "traefik"; }; sops.secrets.cloudflare-dns-api-token = {
sops.secrets.traefik-dashboard-users = { owner = "traefik"; }; owner = "traefik";
};
sops.secrets.traefik-dashboard-users = {
owner = "traefik";
};
cloud.traefik.cloudflareKeyFile = config.sops.secrets.cloudflare-dns-api-token.path; cloud.traefik.cloudflareKeyFile = config.sops.secrets.cloudflare-dns-api-token.path;
cloud.traefik.dashboard = { cloud.traefik.dashboard = {
enable = true; enable = true;
@ -108,9 +120,19 @@
settings.HOST = "127.0.0.1"; settings.HOST = "127.0.0.1";
settings.PORT = "16904"; settings.PORT = "16904";
}; };
cloud.traefik.hosts.uptime-kuma = { host = "status.nkagami.me"; port = 16904; noCloudflare = true; }; cloud.traefik.hosts.uptime-kuma = {
cloud.traefik.hosts.uptime-kuma-dtth = { host = "status.dtth.ch"; port = 16904; }; host = "status.nkagami.me";
cloud.traefik.hosts.uptime-kuma-codefun = { host = "status.codefun.vn"; port = 16904; }; port = 16904;
noCloudflare = true;
};
cloud.traefik.hosts.uptime-kuma-dtth = {
host = "status.dtth.ch";
port = 16904;
};
cloud.traefik.hosts.uptime-kuma-codefun = {
host = "status.codefun.vn";
port = 16904;
};
# Bitwarden # Bitwarden
sops.secrets.vaultwarden-env = { }; sops.secrets.vaultwarden-env = { };
@ -120,7 +142,9 @@
virtualisation.arion.backend = "docker"; virtualisation.arion.backend = "docker";
# Conduit # Conduit
sops.secrets.heisenbridge = { owner = "heisenbridge"; }; sops.secrets.heisenbridge = {
owner = "heisenbridge";
};
cloud.conduit.enable = true; cloud.conduit.enable = true;
cloud.conduit.instances = { cloud.conduit.instances = {
"nkagami" = { "nkagami" = {
@ -155,7 +179,10 @@
}; };
# Mail # Mail
sops.secrets.mail-users = { owner = "maddy"; reloadUnits = [ "maddy.service" ]; }; sops.secrets.mail-users = {
owner = "maddy";
reloadUnits = [ "maddy.service" ];
};
cloud.mail = { cloud.mail = {
enable = true; enable = true;
debug = true; debug = true;
@ -177,7 +204,10 @@
sops.secrets.authentik-env = { }; sops.secrets.authentik-env = { };
cloud.authentik.enable = true; cloud.authentik.enable = true;
cloud.authentik.envFile = config.sops.secrets.authentik-env.path; cloud.authentik.envFile = config.sops.secrets.authentik-env.path;
cloud.traefik.hosts.authentik = { host = "auth.dtth.ch"; port = config.cloud.authentik.port; }; cloud.traefik.hosts.authentik = {
host = "auth.dtth.ch";
port = config.cloud.authentik.port;
};
# Firezone # Firezone
sops.secrets.firezone-env = { }; sops.secrets.firezone-env = { };
@ -197,14 +227,18 @@
}; };
# GoToSocial # GoToSocial
sops.secrets.gts-env = { restartUnits = [ "gotosocial.service" ]; }; sops.secrets.gts-env = {
restartUnits = [ "gotosocial.service" ];
};
cloud.gotosocial = { cloud.gotosocial = {
enable = true; enable = true;
envFile = config.sops.secrets.gts-env.path; envFile = config.sops.secrets.gts-env.path;
}; };
# Grist # Grist
sops.secrets."grist/env" = { restartUnits = [ "arion-grist.service" ]; }; sops.secrets."grist/env" = {
restartUnits = [ "arion-grist.service" ];
};
cloud.grist = { cloud.grist = {
enable = true; enable = true;
envFile = config.sops.secrets."grist/env".path; envFile = config.sops.secrets."grist/env".path;
@ -212,9 +246,12 @@
dataDir = "/mnt/data/grist"; dataDir = "/mnt/data/grist";
}; };
# ntfy # ntfy
cloud.traefik.hosts.ntfy-sh = { host = "ntfy.nkagami.me"; port = 11161; noCloudflare = true; }; cloud.traefik.hosts.ntfy-sh = {
host = "ntfy.nkagami.me";
port = 11161;
noCloudflare = true;
};
services.ntfy-sh = { services.ntfy-sh = {
enable = true; enable = true;
settings = { settings = {
@ -238,4 +275,3 @@
mkdir -p /var/lib/ntfy-sh/attachments mkdir -p /var/lib/ntfy-sh/attachments
''; '';
} }

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let
user = "gitea"; user = "gitea";
@ -126,7 +131,11 @@ in
}; };
repository = { repository = {
DEFAULT_PRIVATE = "private"; DEFAULT_PRIVATE = "private";
PREFERRED_LICENSES = strings.concatStringsSep "," [ "AGPL-3.0-or-later" "GPL-3.0-or-later" "Apache-2.0" ]; PREFERRED_LICENSES = strings.concatStringsSep "," [
"AGPL-3.0-or-later"
"GPL-3.0-or-later"
"Apache-2.0"
];
# DISABLE_HTTP_GIT = true; # DISABLE_HTTP_GIT = true;
DEFAULT_BRANCH = "master"; DEFAULT_BRANCH = "master";
ENABLE_PUSH_CREATE_USER = true; ENABLE_PUSH_CREATE_USER = true;
@ -216,8 +225,7 @@ in
environment.GNUPGHOME = "${config.services.gitea.stateDir}/.gnupg"; environment.GNUPGHOME = "${config.services.gitea.stateDir}/.gnupg";
# https://github.com/NixOS/nixpkgs/commit/93c1d370db28ad4573fb9890c90164ba55391ce7 # https://github.com/NixOS/nixpkgs/commit/93c1d370db28ad4573fb9890c90164ba55391ce7
serviceConfig.SystemCallFilter = mkForce "~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io @reboot @setuid @swap"; serviceConfig.SystemCallFilter = mkForce "~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io @reboot @setuid @swap";
preStart = preStart = ''
''
# Import the signing subkey # Import the signing subkey
if cat ${config.services.forgejo.stateDir}/.gnupg/gpg.conf | grep -q ${signingKey}; then if cat ${config.services.forgejo.stateDir}/.gnupg/gpg.conf | grep -q ${signingKey}; then
echo "Keys already imported" echo "Keys already imported"

View file

@ -1,11 +1,15 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let
cfg = config.cloud.grist; cfg = config.cloud.grist;
mkImage = mkImage = { imageName, imageDigest, ... }: "${imageName}@${imageDigest}";
{ imageName, imageDigest, ... }: "${imageName}@${imageDigest}";
# If we can pullImage we can just do # If we can pullImage we can just do
# mkImage = pkgs.dockerTools.pullImage; # mkImage = pkgs.dockerTools.pullImage;
@ -24,7 +28,12 @@ let
}; };
}; };
defaultEnv = { defaultEnv = {
GRIST_HIDE_UI_ELEMENTS = lib.concatStringsSep "," [ "helpCenter" "billing" "multiAccounts" "supportGrist" ]; GRIST_HIDE_UI_ELEMENTS = lib.concatStringsSep "," [
"helpCenter"
"billing"
"multiAccounts"
"supportGrist"
];
GRIST_PAGE_TITLE_SUFFIX = " - DTTH Grist"; GRIST_PAGE_TITLE_SUFFIX = " - DTTH Grist";
GRIST_FORCE_LOGIN = "true"; GRIST_FORCE_LOGIN = "true";
GRIST_WIDGET_LIST_URL = "https://github.com/gristlabs/grist-widget/releases/download/latest/manifest.json"; GRIST_WIDGET_LIST_URL = "https://github.com/gristlabs/grist-widget/releases/download/latest/manifest.json";
@ -60,7 +69,11 @@ in
allowedWebhookDomains = mkOption { allowedWebhookDomains = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
description = "List of domains to be allowed in webhooks"; description = "List of domains to be allowed in webhooks";
default = [ "dtth.ch" "nkagami.me" "discord.com" ]; default = [
"dtth.ch"
"nkagami.me"
"discord.com"
];
}; };
defaultEmail = mkOption { defaultEmail = mkOption {
type = types.str; type = types.str;
@ -105,7 +118,10 @@ in
command = "--save 60 1 --loglevel warning"; command = "--save 60 1 --loglevel warning";
restart = "unless-stopped"; restart = "unless-stopped";
healthcheck = { healthcheck = {
test = [ "CMD-SHELL" "valkey-cli ping | grep PONG" ]; test = [
"CMD-SHELL"
"valkey-cli ping | grep PONG"
];
start_period = "20s"; start_period = "20s";
interval = "30s"; interval = "30s";
retries = 5; retries = 5;
@ -124,4 +140,3 @@ in
}; };
}; };
} }

View file

@ -2,11 +2,25 @@
{ {
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
boot.loader.grub.device = "/dev/sda"; boot.loader.grub.device = "/dev/sda";
boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "xen_blkfront" "vmw_pvscsi" ]; boot.initrd.availableKernelModules = [
"ata_piix"
"uhci_hcd"
"xen_blkfront"
"vmw_pvscsi"
];
boot.initrd.kernelModules = [ "nvme" ]; boot.initrd.kernelModules = [ "nvme" ];
fileSystems."/" = { device = "/dev/sda1"; fsType = "ext4"; }; fileSystems."/" = {
device = "/dev/sda1";
fsType = "ext4";
};
# swap # swap
swapDevices = [{ device = "/var/swapfile"; size = 4 * 1024; priority = 1024; }]; swapDevices = [
{
device = "/var/swapfile";
size = 4 * 1024;
priority = 1024;
}
];
zramSwap.enable = true; zramSwap.enable = true;
# volumes # volumes
services.btrfs.autoScrub.enable = true; services.btrfs.autoScrub.enable = true;

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
secrets = config.sops.secrets; secrets = config.sops.secrets;
@ -7,9 +12,14 @@ let
webuiPort = 19877; webuiPort = 19877;
in in
rec { rec {
sops.secrets."headscale/client_secret" = { owner = "headscale"; }; sops.secrets."headscale/client_secret" = {
owner = "headscale";
};
sops.secrets."headscale/webui-env" = { }; sops.secrets."headscale/webui-env" = { };
sops.secrets."headscale/derp-servers/vnm" = { owner = "headscale"; name = "headscale/derp-servers/vnm.yaml"; }; sops.secrets."headscale/derp-servers/vnm" = {
owner = "headscale";
name = "headscale/derp-servers/vnm.yaml";
};
# database # database
cloud.postgresql.databases = [ "headscale" ]; cloud.postgresql.databases = [ "headscale" ];
# traefik # traefik
@ -27,8 +37,14 @@ rec {
noCloudflare = true; noCloudflare = true;
}; };
systemd.services.headscale.requires = [ "postgresql.service" "arion-authentik.service" ]; systemd.services.headscale.requires = [
systemd.services.headscale.after = [ "postgresql.service" "arion-authentik.service" ]; "postgresql.service"
"arion-authentik.service"
];
systemd.services.headscale.after = [
"postgresql.service"
"arion-authentik.service"
];
services.headscale = { services.headscale = {
enable = true; enable = true;
inherit port; inherit port;

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
ipv6-rotator = ipv6-rotator =
let let
@ -11,7 +16,14 @@ let
in in
pkgs.writeShellApplication { pkgs.writeShellApplication {
name = "smart-ipv6-rotator"; name = "smart-ipv6-rotator";
runtimeInputs = [ (pkgs.python3.withPackages (p: with p; [ pyroute2 requests ])) ]; runtimeInputs = [
(pkgs.python3.withPackages (
p: with p; [
pyroute2
requests
]
))
];
text = '' text = ''
if [ -z "$IPV6_ROTATOR_RANGE" ]; then if [ -z "$IPV6_ROTATOR_RANGE" ]; then
echo "Range required" echo "Range required"
@ -22,10 +34,17 @@ let
}; };
in in
{ {
sops.secrets."invidious" = { mode = "0444"; }; sops.secrets."invidious" = {
sops.secrets."invidious-rotator-env" = { mode = "0444"; }; mode = "0444";
};
sops.secrets."invidious-rotator-env" = {
mode = "0444";
};
cloud.postgresql.databases = [ "invidious" ]; cloud.postgresql.databases = [ "invidious" ];
cloud.traefik.hosts.invidious = { host = "invi.dtth.ch"; port = 61191; }; cloud.traefik.hosts.invidious = {
host = "invi.dtth.ch";
port = 61191;
};
services.invidious = { services.invidious = {
enable = true; enable = true;
domain = "invi.dtth.ch"; domain = "invi.dtth.ch";
@ -54,8 +73,13 @@ in
}; };
systemd.timers.smart-ipv6-rotator = { systemd.timers.smart-ipv6-rotator = {
description = "Rotate ipv6 routes to Google"; description = "Rotate ipv6 routes to Google";
timerConfig = { OnCalendar = "*-*-* 00,06,12,18:00:00"; }; timerConfig = {
wantedBy = [ "invidious.service" "timers.target" ]; OnCalendar = "*-*-* 00,06,12,18:00:00";
};
wantedBy = [
"invidious.service"
"timers.target"
];
unitConfig = { }; unitConfig = { };
}; };
systemd.services.smart-ipv6-rotator = { systemd.services.smart-ipv6-rotator = {
@ -68,4 +92,3 @@ in
}; };
}; };
} }

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
with lib; with lib;
let let
user = "miniflux"; user = "miniflux";
@ -42,7 +47,10 @@ in
systemd.services.miniflux = { systemd.services.miniflux = {
description = "Miniflux service"; description = "Miniflux service";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "network.target" "postgresql.service" ]; after = [
"network.target"
"postgresql.service"
];
requires = [ "postgresql.service" ]; requires = [ "postgresql.service" ];
serviceConfig = { serviceConfig = {
@ -72,16 +80,22 @@ in
ProtectKernelModules = true; ProtectKernelModules = true;
ProtectKernelTunables = true; ProtectKernelTunables = true;
ProtectProc = "invisible"; ProtectProc = "invisible";
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ]; RestrictAddressFamilies = [
"AF_INET"
"AF_INET6"
"AF_UNIX"
];
RestrictNamespaces = true; RestrictNamespaces = true;
RestrictRealtime = true; RestrictRealtime = true;
RestrictSUIDSGID = true; RestrictSUIDSGID = true;
SystemCallArchitectures = "native"; SystemCallArchitectures = "native";
SystemCallFilter = [ "@system-service" "~@privileged" ]; SystemCallFilter = [
"@system-service"
"~@privileged"
];
UMask = "0077"; UMask = "0077";
}; };
environment = configEnv; environment = configEnv;
}; };
} }

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
secrets = config.sops.secrets; secrets = config.sops.secrets;
@ -12,7 +17,9 @@ let
plugins = pkgs.callPackage ./n8n/plugins/package.nix { }; plugins = pkgs.callPackage ./n8n/plugins/package.nix { };
in in
{ {
sops.secrets."n8n/env" = { reloadUnits = [ "n8n.service" ]; }; sops.secrets."n8n/env" = {
reloadUnits = [ "n8n.service" ];
};
cloud.postgresql.databases = [ db ]; cloud.postgresql.databases = [ db ];
cloud.traefik.hosts.n8n = { cloud.traefik.hosts.n8n = {
inherit port host; inherit port host;

View file

@ -1,4 +1,5 @@
{ nodejs, importNpmLock }: importNpmLock.buildNodeModules { { nodejs, importNpmLock }:
importNpmLock.buildNodeModules {
inherit nodejs; inherit nodejs;
npmRoot = ./.; npmRoot = ./.;
} }

View file

@ -1,7 +1,14 @@
{ config, pkgs, ... }: { { config, pkgs, ... }:
sops.secrets.authentik-oidc-client-secret = { owner = "outline"; }; {
sops.secrets."outline/smtp-password" = { owner = "outline"; }; sops.secrets.authentik-oidc-client-secret = {
sops.secrets."outline/s3-secret-key" = { owner = "outline"; }; owner = "outline";
};
sops.secrets."outline/smtp-password" = {
owner = "outline";
};
sops.secrets."outline/s3-secret-key" = {
owner = "outline";
};
services.outline = { services.outline = {
enable = true; enable = true;
@ -52,5 +59,8 @@
AWS_S3_R2 = "true"; AWS_S3_R2 = "true";
AWS_S3_R2_PUBLIC_URL = "https://s3.wiki.dtth.ch"; AWS_S3_R2_PUBLIC_URL = "https://s3.wiki.dtth.ch";
}; };
cloud.traefik.hosts.outline = { host = "wiki.dtth.ch"; port = 18729; }; cloud.traefik.hosts.outline = {
host = "wiki.dtth.ch";
port = 18729;
};
} }

View file

@ -1,4 +1,9 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
host = "owncast.nkagami.me"; host = "owncast.nkagami.me";
port = 61347; port = 61347;

View file

@ -1,4 +1,9 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
secrets = config.sops.secrets; secrets = config.sops.secrets;
cfg = config.services.peertube; cfg = config.services.peertube;
@ -9,8 +14,14 @@ let
port = 19878; port = 19878;
in in
{ {
sops.secrets."peertube" = { owner = cfg.user; restartUnits = [ "peertube.service" ]; }; sops.secrets."peertube" = {
sops.secrets."peertube-env" = { owner = cfg.user; restartUnits = [ "peertube.service" ]; }; owner = cfg.user;
restartUnits = [ "peertube.service" ];
};
sops.secrets."peertube-env" = {
owner = cfg.user;
restartUnits = [ "peertube.service" ];
};
# database # database
cloud.postgresql.databases = [ "peertube" ]; cloud.postgresql.databases = [ "peertube" ];
# traefik # traefik
@ -61,7 +72,9 @@ in
}; };
# Trust proxy # Trust proxy
settings.trust_proxy = [ "loopback" ] ++ config.services.traefik.staticConfigOptions.entrypoints.https.forwardedHeaders.trustedIPs; settings.trust_proxy = [
"loopback"
] ++ config.services.traefik.staticConfigOptions.entrypoints.https.forwardedHeaders.trustedIPs;
# Federation # Federation
settings.federation = { settings.federation = {
@ -70,7 +83,10 @@ in
videos.cleanup_remote_interactions = true; videos.cleanup_remote_interactions = true;
}; };
dataDirs = [ "/var/lib/peertube" "/mnt/data/peertube" ]; dataDirs = [
"/var/lib/peertube"
"/mnt/data/peertube"
];
}; };
systemd.services.peertube = { systemd.services.peertube = {
@ -90,4 +106,3 @@ in
}; };
}; };
} }

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
host = "social.dtth.ch"; host = "social.dtth.ch";
port = 61010; port = 61010;
@ -6,11 +11,12 @@ in
{ {
cloud.traefik.hosts.phanpy = { inherit host port; }; cloud.traefik.hosts.phanpy = { inherit host port; };
services.nginx.virtualHosts.phanpy = { services.nginx.virtualHosts.phanpy = {
listen = [{ listen = [
{
inherit port; inherit port;
addr = "127.0.0.1"; addr = "127.0.0.1";
}]; }
];
root = "${pkgs.dtth-phanpy}/lib/phanpy"; root = "${pkgs.dtth-phanpy}/lib/phanpy";
}; };
} }

View file

@ -1,4 +1,9 @@
{ pkgs, lib, config, ... }: {
pkgs,
lib,
config,
...
}:
let let
port = 61001; port = 61001;
user = "matrix-synapse"; user = "matrix-synapse";
@ -10,7 +15,9 @@ in
{ {
sops.secrets."matrix-synapse-dtth/oidc-config".owner = user; sops.secrets."matrix-synapse-dtth/oidc-config".owner = user;
sops.secrets."matrix-synapse-dtth/appservice-discord".owner = user; sops.secrets."matrix-synapse-dtth/appservice-discord".owner = user;
sops.secrets.matrix-discord-bridge = { mode = "0644"; }; sops.secrets.matrix-discord-bridge = {
mode = "0644";
};
cloud.postgresql.databases = [ user ]; cloud.postgresql.databases = [ user ];
cloud.traefik.hosts.matrix-synapse = { cloud.traefik.hosts.matrix-synapse = {
@ -29,20 +36,33 @@ in
enable = true; enable = true;
withJemalloc = true; withJemalloc = true;
dataDir = "${config.fileSystems.data.mountPoint}/matrix-synapse-dtth"; dataDir = "${config.fileSystems.data.mountPoint}/matrix-synapse-dtth";
extras = [ "systemd" "url-preview" "oidc" "postgres" ]; extras = [
"systemd"
"url-preview"
"oidc"
"postgres"
];
settings = { settings = {
server_name = "dtth.ch"; server_name = "dtth.ch";
enable_registration = false; enable_registration = false;
public_baseurl = "https://${host}/"; public_baseurl = "https://${host}/";
listeners = [{ listeners = [
{
inherit port; inherit port;
x_forwarded = true; x_forwarded = true;
tls = false; tls = false;
resources = [ resources = [
{ names = [ "client" "federation" ]; compress = false; } {
names = [
"client"
"federation"
];
compress = false;
}
];
}
]; ];
}];
database = { database = {
name = "psycopg2"; name = "psycopg2";
args = { args = {
@ -96,19 +116,27 @@ in
}; };
services.nginx.virtualHosts.synapse-dtth-wellknown = { services.nginx.virtualHosts.synapse-dtth-wellknown = {
listen = [{ addr = "127.0.0.1"; port = port + 1; }]; listen = [
{
addr = "127.0.0.1";
port = port + 1;
}
];
# Check https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/configuring-well-known.md # Check https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/configuring-well-known.md
# for the file structure. # for the file structure.
root = pkgs.symlinkJoin root = pkgs.symlinkJoin {
{
name = "well-known-files-for-synapse"; name = "well-known-files-for-synapse";
paths = [ paths = [
(pkgs.writeTextDir ".well-known/matrix/client" (builtins.toJSON { (pkgs.writeTextDir ".well-known/matrix/client" (
builtins.toJSON {
"m.homeserver".base_url = "https://${host}"; "m.homeserver".base_url = "https://${host}";
})) }
(pkgs.writeTextDir ".well-known/matrix/server" (builtins.toJSON { ))
(pkgs.writeTextDir ".well-known/matrix/server" (
builtins.toJSON {
"m.server" = "${host}:443"; "m.server" = "${host}:443";
})) }
))
]; ];
}; };
# Enable CORS from anywhere since we want all clients to find us out # Enable CORS from anywhere since we want all clients to find us out
@ -117,4 +145,3 @@ in
''; '';
}; };
} }

View file

@ -1,4 +1,9 @@
{ pkgs, lib, config, ... }: {
pkgs,
lib,
config,
...
}:
let let
secrets = config.sops.secrets; secrets = config.sops.secrets;
@ -9,8 +14,12 @@ let
storageMount = "/mnt/data/vikunja"; storageMount = "/mnt/data/vikunja";
in in
{ {
sops.secrets."vikunja/env" = { restartUnits = [ "vikunja.service" ]; }; sops.secrets."vikunja/env" = {
sops.secrets."vikunja/provider-clientsecret" = { restartUnits = [ "vikunja.service" ]; }; restartUnits = [ "vikunja.service" ];
};
sops.secrets."vikunja/provider-clientsecret" = {
restartUnits = [ "vikunja.service" ];
};
cloud.postgresql.databases = [ user ]; cloud.postgresql.databases = [ user ];
cloud.traefik.hosts.vikunja = { cloud.traefik.hosts.vikunja = {
inherit port host; inherit port host;
@ -23,7 +32,6 @@ in
}; };
users.groups."${user}" = { }; users.groups."${user}" = { };
services.vikunja = { services.vikunja = {
inherit port; inherit port;
enable = true; enable = true;
@ -81,7 +89,11 @@ in
}; };
systemd.services.vikunja = { systemd.services.vikunja = {
serviceConfig.LoadCredential = [ "VIKUNJA_AUTH_OPENID_PROVIDERS_AUTHENTIK_CLIENTSECRET_FILE:${secrets."vikunja/provider-clientsecret".path}" ]; serviceConfig.LoadCredential = [
"VIKUNJA_AUTH_OPENID_PROVIDERS_AUTHENTIK_CLIENTSECRET_FILE:${
secrets."vikunja/provider-clientsecret".path
}"
];
serviceConfig.User = user; serviceConfig.User = user;
serviceConfig.DynamicUser = lib.mkForce false; serviceConfig.DynamicUser = lib.mkForce false;
serviceConfig.ReadWritePaths = [ storageMount ]; serviceConfig.ReadWritePaths = [ storageMount ];
@ -96,4 +108,3 @@ in
mode = "0700"; mode = "0700";
}; };
} }

View file

@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
with lib; with lib;
let let
host = "blog.dtth.ch"; host = "blog.dtth.ch";
@ -11,7 +16,9 @@ in
# traefik # traefik
cloud.traefik.hosts.writefreely-dtth = { inherit host port; }; cloud.traefik.hosts.writefreely-dtth = { inherit host port; };
sops.secrets."writefreely-oauth-secret" = { owner = user; }; sops.secrets."writefreely-oauth-secret" = {
owner = user;
};
users.users.${user} = { users.users.${user} = {
isSystemUser = true; isSystemUser = true;
@ -65,16 +72,18 @@ in
tokenEndpoint = "/application/o/token/"; tokenEndpoint = "/application/o/token/";
inspectEndpoint = "/application/o/userinfo/"; inspectEndpoint = "/application/o/userinfo/";
authEndpoint = "/application/o/authorize/"; authEndpoint = "/application/o/authorize/";
scopes = [ "email" "openid" "profile" ]; scopes = [
"email"
"openid"
"profile"
];
mapUserId = "nickname"; mapUserId = "nickname";
mapUsername = "preferred_username"; mapUsername = "preferred_username";
mapDisplayName = "name"; mapDisplayName = "name";
}; };
database.type = "sqlite3"; database.type = "sqlite3";
admin.name = "nki"; admin.name = "nki";
}; };
} }

View file

@ -1,21 +1,36 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
inherit (builtins) toString; inherit (builtins) toString;
inherit (lib) types mkIf mkOption mkDefault; inherit (lib)
inherit (lib) optional optionals optionalAttrs optionalString; types
mkIf
mkOption
mkDefault
;
inherit (lib)
optional
optionals
optionalAttrs
optionalString
;
inherit (pkgs) sqlite; inherit (pkgs) sqlite;
format = pkgs.formats.ini { format = pkgs.formats.ini {
mkKeyValue = key: value: mkKeyValue =
key: value:
let let
value' = lib.optionalString (value != null) value' = lib.optionalString (value != null) (
(if builtins.isBool value then if builtins.isBool value then if value == true then "true" else "false" else toString value
if value == true then "true" else "false" );
else in
toString value); "${key} = ${value'}";
in "${key} = ${value'}";
}; };
cfg = config.nki.services.writefreely; cfg = config.nki.services.writefreely;
@ -31,11 +46,15 @@ let
host = cfg.settings.app.host or "${hostProtocol}://${cfg.host}"; host = cfg.settings.app.host or "${hostProtocol}://${cfg.host}";
}; };
database = if cfg.database.type == "sqlite3" then { database =
if cfg.database.type == "sqlite3" then
{
type = "sqlite3"; type = "sqlite3";
filename = cfg.settings.database.filename or "writefreely.db"; filename = cfg.settings.database.filename or "writefreely.db";
database = cfg.database.name; database = cfg.database.name;
} else { }
else
{
type = "mysql"; type = "mysql";
username = cfg.database.user; username = cfg.database.user;
password = "#dbpass#"; password = "#dbpass#";
@ -49,15 +68,17 @@ let
bind = cfg.settings.server.bind or "localhost"; bind = cfg.settings.server.bind or "localhost";
gopher_port = cfg.settings.server.gopher_port or 0; gopher_port = cfg.settings.server.gopher_port or 0;
autocert = !cfg.nginx.enable && cfg.acme.enable; autocert = !cfg.nginx.enable && cfg.acme.enable;
templates_parent_dir = templates_parent_dir = cfg.settings.server.templates_parent_dir or cfg.package.src;
cfg.settings.server.templates_parent_dir or cfg.package.src;
static_parent_dir = cfg.settings.server.static_parent_dir or assets; static_parent_dir = cfg.settings.server.static_parent_dir or assets;
pages_parent_dir = pages_parent_dir = cfg.settings.server.pages_parent_dir or cfg.package.src;
cfg.settings.server.pages_parent_dir or cfg.package.src;
keys_parent_dir = cfg.settings.server.keys_parent_dir or cfg.stateDir; keys_parent_dir = cfg.settings.server.keys_parent_dir or cfg.stateDir;
}; };
"oauth.generic" = cfg.settings."oauth.generic" or { } // (if cfg.oauth.enable then { "oauth.generic" =
cfg.settings."oauth.generic" or { }
// (
if cfg.oauth.enable then
{
client_id = cfg.oauth.clientId; client_id = cfg.oauth.clientId;
client_secret = "#oauth_client_secret#"; client_secret = "#oauth_client_secret#";
host = cfg.oauth.host; host = cfg.oauth.host;
@ -73,7 +94,10 @@ let
map_username = cfg.oauth.mapUsername; map_username = cfg.oauth.mapUsername;
map_display_name = cfg.oauth.mapDisplayName; map_display_name = cfg.oauth.mapDisplayName;
map_email = cfg.oauth.mapEmail; map_email = cfg.oauth.mapEmail;
} else { }); }
else
{ }
);
}; };
configFile = format.generate "config.ini" settings; configFile = format.generate "config.ini" settings;
@ -104,13 +128,9 @@ let
withConfigFile = text: '' withConfigFile = text: ''
db_pass=${ db_pass=${
optionalString (cfg.database.passwordFile != null) optionalString (cfg.database.passwordFile != null) "$(head -n1 ${cfg.database.passwordFile})"
"$(head -n1 ${cfg.database.passwordFile})"
}
oauth_client_secret=${
optionalString cfg.oauth.enable
"$(head -n1 ${cfg.oauth.clientSecretFile})"
} }
oauth_client_secret=${optionalString cfg.oauth.enable "$(head -n1 ${cfg.oauth.clientSecretFile})"}
cp -f ${configFile} '${cfg.stateDir}/config.ini' cp -f ${configFile} '${cfg.stateDir}/config.ini'
sed -e "s,#dbpass#,$db_pass,g" -i '${cfg.stateDir}/config.ini' sed -e "s,#dbpass#,$db_pass,g" -i '${cfg.stateDir}/config.ini'
@ -120,7 +140,8 @@ let
${text} ${text}
''; '';
withMysql = text: withMysql =
text:
withConfigFile '' withConfigFile ''
query () { query () {
local result=$(${config.services.mysql.package}/bin/mysql \ local result=$(${config.services.mysql.package}/bin/mysql \
@ -139,7 +160,8 @@ let
${text} ${text}
''; '';
withSqlite = text: withSqlite =
text:
withConfigFile '' withConfigFile ''
query () { query () {
local result=$(${sqlite}/bin/sqlite3 \ local result=$(${sqlite}/bin/sqlite3 \
@ -152,10 +174,10 @@ let
${text} ${text}
''; '';
in { in
{
options.nki.services.writefreely = { options.nki.services.writefreely = {
enable = enable = lib.mkEnableOption "Writefreely, build a digital writing community";
lib.mkEnableOption "Writefreely, build a digital writing community";
package = lib.mkOption { package = lib.mkOption {
type = lib.types.package; type = lib.types.package;
@ -223,7 +245,10 @@ in {
database = { database = {
type = mkOption { type = mkOption {
type = types.enum [ "sqlite3" "mysql" ]; type = types.enum [
"sqlite3"
"mysql"
];
default = "sqlite3"; default = "sqlite3";
description = "The database provider to use."; description = "The database provider to use.";
}; };
@ -416,13 +441,11 @@ in {
} }
{ {
assertion = isMysqlLocal -> cfg.database.passwordFile != null; assertion = isMysqlLocal -> cfg.database.passwordFile != null;
message = message = "services.writefreely.database.passwordFile must be set if services.writefreely.database.createLocally is set to true";
"services.writefreely.database.passwordFile must be set if services.writefreely.database.createLocally is set to true";
} }
{ {
assertion = isSqlite -> !cfg.database.createLocally; assertion = isSqlite -> !cfg.database.createLocally;
message = message = "services.writefreely.database.createLocally has no use when services.writefreely.database.type is set to sqlite3";
"services.writefreely.database.createLocally has no use when services.writefreely.database.type is set to sqlite3";
} }
]; ];
@ -435,8 +458,7 @@ in {
}; };
}; };
groups = groups = optionalAttrs (cfg.group == "writefreely") { writefreely = { }; };
optionalAttrs (cfg.group == "writefreely") { writefreely = { }; };
}; };
systemd.tmpfiles.settings."10-writefreely".${cfg.stateDir}.d = { systemd.tmpfiles.settings."10-writefreely".${cfg.stateDir}.d = {
@ -445,7 +467,8 @@ in {
}; };
systemd.services.writefreely = { systemd.services.writefreely = {
after = [ "network.target" ] after =
[ "network.target" ]
++ optional isSqlite "writefreely-sqlite-init.service" ++ optional isSqlite "writefreely-sqlite-init.service"
++ optional isMysql "writefreely-mysql-init.service" ++ optional isMysql "writefreely-mysql-init.service"
++ optional isMysqlLocal "mysql.service"; ++ optional isMysqlLocal "mysql.service";
@ -458,10 +481,8 @@ in {
WorkingDirectory = cfg.stateDir; WorkingDirectory = cfg.stateDir;
Restart = "always"; Restart = "always";
RestartSec = 20; RestartSec = 20;
ExecStart = ExecStart = "${cfg.package}/bin/writefreely -c '${cfg.stateDir}/config.ini' serve";
"${cfg.package}/bin/writefreely -c '${cfg.stateDir}/config.ini' serve"; AmbientCapabilities = optionalString (settings.server.port < 1024) "cap_net_bind_service";
AmbientCapabilities =
optionalString (settings.server.port < 1024) "cap_net_bind_service";
}; };
preStart = '' preStart = ''
@ -485,11 +506,11 @@ in {
User = cfg.user; User = cfg.user;
Group = cfg.group; Group = cfg.group;
WorkingDirectory = cfg.stateDir; WorkingDirectory = cfg.stateDir;
ReadOnlyPaths = optional (cfg.admin.initialPasswordFile != null) ReadOnlyPaths = optional (cfg.admin.initialPasswordFile != null) cfg.admin.initialPasswordFile;
cfg.admin.initialPasswordFile;
}; };
script = let script =
let
migrateDatabase = optionalString cfg.database.migrate '' migrateDatabase = optionalString cfg.database.migrate ''
${cfg.package}/bin/writefreely -c '${cfg.stateDir}/config.ini' db migrate ${cfg.package}/bin/writefreely -c '${cfg.stateDir}/config.ini' db migrate
''; '';
@ -501,7 +522,8 @@ in {
${cfg.package}/bin/writefreely -c '${cfg.stateDir}/config.ini' --create-admin ${cfg.admin.name}:$admin_pass ${cfg.package}/bin/writefreely -c '${cfg.stateDir}/config.ini' --create-admin ${cfg.admin.name}:$admin_pass
fi fi
''; '';
in withSqlite '' in
withSqlite ''
if ! test -f '${settings.database.filename}'; then if ! test -f '${settings.database.filename}'; then
${cfg.package}/bin/writefreely -c '${cfg.stateDir}/config.ini' db init ${cfg.package}/bin/writefreely -c '${cfg.stateDir}/config.ini' db init
fi fi
@ -521,12 +543,13 @@ in {
User = cfg.user; User = cfg.user;
Group = cfg.group; Group = cfg.group;
WorkingDirectory = cfg.stateDir; WorkingDirectory = cfg.stateDir;
ReadOnlyPaths = optional isMysqlLocal cfg.database.passwordFile ReadOnlyPaths =
++ optional (cfg.admin.initialPasswordFile != null) optional isMysqlLocal cfg.database.passwordFile
cfg.admin.initialPasswordFile; ++ optional (cfg.admin.initialPasswordFile != null) cfg.admin.initialPasswordFile;
}; };
script = let script =
let
updateUser = optionalString isMysqlLocal '' updateUser = optionalString isMysqlLocal ''
# WriteFreely currently *requires* a password for authentication, so we # WriteFreely currently *requires* a password for authentication, so we
# need to update the user in MySQL accordingly. By default MySQL users # need to update the user in MySQL accordingly. By default MySQL users
@ -545,7 +568,8 @@ in {
${cfg.package}/bin/writefreely -c '${cfg.stateDir}/config.ini' --create-admin ${cfg.admin.name}:$admin_pass ${cfg.package}/bin/writefreely -c '${cfg.stateDir}/config.ini' --create-admin ${cfg.admin.name}:$admin_pass
fi fi
''; '';
in withMysql '' in
withMysql ''
${updateUser} ${updateUser}
if [[ $(query "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '${cfg.database.name}'") == 0 ]]; then if [[ $(query "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '${cfg.database.name}'") == 0 ]]; then
@ -562,7 +586,8 @@ in {
enable = true; enable = true;
package = mkDefault pkgs.mariadb; package = mkDefault pkgs.mariadb;
ensureDatabases = [ cfg.database.name ]; ensureDatabases = [ cfg.database.name ];
ensureUsers = [{ ensureUsers = [
{
name = cfg.database.user; name = cfg.database.user;
ensurePermissions = { ensurePermissions = {
"${cfg.database.name}.*" = "ALL PRIVILEGES"; "${cfg.database.name}.*" = "ALL PRIVILEGES";
@ -571,7 +596,8 @@ in {
# permissions so they can be used. # permissions so they can be used.
"*.*" = "CREATE USER, RELOAD"; "*.*" = "CREATE USER, RELOAD";
}; };
}]; }
];
}; };
services.nginx = lib.mkIf cfg.nginx.enable { services.nginx = lib.mkIf cfg.nginx.enable {

View file

@ -5,8 +5,7 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
imports = imports = [
[
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
# Fonts # Fonts
@ -54,7 +53,6 @@
services.xserver.enable = true; services.xserver.enable = true;
services.xserver.autorun = false; services.xserver.autorun = false;
# Enable the Plasma 5 Desktop Environment. # Enable the Plasma 5 Desktop Environment.
# services.xserver.displayManager.sddm.enable = true; # services.xserver.displayManager.sddm.enable = true;
# services.xserver.desktopManager.plasma5.enable = true; # services.xserver.desktopManager.plasma5.enable = true;
@ -65,13 +63,18 @@
fi fi
''; '';
# Configure keymap in X11 # Configure keymap in X11
# services.xserver.layout = "us"; # services.xserver.layout = "us";
# services.xserver.xkbOptions = "eurosign:e"; # services.xserver.xkbOptions = "eurosign:e";
i18n.inputMethod.enabled = "ibus"; i18n.inputMethod.enabled = "ibus";
i18n.inputMethod.ibus.engines = (with pkgs.ibus-engines; [ bamboo mozc libpinyin ]); i18n.inputMethod.ibus.engines = (
with pkgs.ibus-engines;
[
bamboo
mozc
libpinyin
]
);
# Enable CUPS to print documents. # Enable CUPS to print documents.
# services.printing.enable = true; # services.printing.enable = true;

View file

@ -1,39 +1,47 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: {
config,
lib,
pkgs,
modulesPath,
...
}:
{ {
imports = imports = [
[
(modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
]; ];
boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "sd_mod" "sdhci_pci" ]; boot.initrd.availableKernelModules = [
"xhci_pci"
"ehci_pci"
"ahci"
"usb_storage"
"sd_mod"
"sdhci_pci"
];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" = {
{
device = "/dev/disk/by-uuid/bc8b0807-c3d6-4893-bcc2-02f059a51a80"; device = "/dev/disk/by-uuid/bc8b0807-c3d6-4893-bcc2-02f059a51a80";
fsType = "ext4"; fsType = "ext4";
}; };
fileSystems."/boot" = fileSystems."/boot" = {
{
device = "/dev/disk/by-uuid/885D-D058"; device = "/dev/disk/by-uuid/885D-D058";
fsType = "vfat"; fsType = "vfat";
}; };
fileSystems."/home" = fileSystems."/home" = {
{
device = "/dev/disk/by-uuid/a981870f-db1d-4441-81da-f1bab1ecc37c"; device = "/dev/disk/by-uuid/a981870f-db1d-4441-81da-f1bab1ecc37c";
fsType = "btrfs"; fsType = "btrfs";
}; };
swapDevices = swapDevices = [ { device = "/dev/disk/by-uuid/2694d189-2ff6-4719-a449-367c52ed3ad6"; } ];
[{ device = "/dev/disk/by-uuid/2694d189-2ff6-4719-a449-367c52ed3ad6"; }];
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
} }

View file

@ -5,8 +5,7 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
imports = imports = [
[
# Include the results of the hardware scan. # Include the results of the hardware scan.
./hardware-configuration.nix ./hardware-configuration.nix
# Fonts # Fonts
@ -20,7 +19,9 @@
common.linux.sops.file = ./secrets.yaml; common.linux.sops.file = ./secrets.yaml;
# Build farm # Build farm
sops.secrets."nix-build-farm/private-key" = { mode = "0400"; }; sops.secrets."nix-build-farm/private-key" = {
mode = "0400";
};
services.nix-build-farm.hostname = "yoga"; services.nix-build-farm.hostname = "yoga";
services.nix-build-farm.privateKeyFile = config.sops.secrets."nix-build-farm/private-key".path; services.nix-build-farm.privateKeyFile = config.sops.secrets."nix-build-farm/private-key".path;
@ -141,4 +142,3 @@
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.05"; # Did you read the comment? system.stateVersion = "22.05"; # Did you read the comment?
} }

View file

@ -1,15 +1,24 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: {
config,
lib,
pkgs,
modulesPath,
...
}:
{ {
imports = imports = [
[
(modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
]; ];
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" ]; boot.initrd.availableKernelModules = [
"xhci_pci"
"thunderbolt"
"nvme"
];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
@ -19,8 +28,7 @@
"resume_offset=9731998" # btrfs inspect-internal map-swapfile -r /var/swapfile "resume_offset=9731998" # btrfs inspect-internal map-swapfile -r /var/swapfile
]; ];
fileSystems."/" = fileSystems."/" = {
{
device = "/dev/disk/by-uuid/b32d27bf-9df6-43c1-8b93-c0693811bf5b"; device = "/dev/disk/by-uuid/b32d27bf-9df6-43c1-8b93-c0693811bf5b";
fsType = "btrfs"; fsType = "btrfs";
}; };
@ -31,14 +39,17 @@
common.linux.luksDevices."nixroot" = "/dev/disk/by-uuid/09114015-79bc-4a40-bf60-b4022e969acb"; common.linux.luksDevices."nixroot" = "/dev/disk/by-uuid/09114015-79bc-4a40-bf60-b4022e969acb";
fileSystems."/boot" = fileSystems."/boot" = {
{
device = "/dev/disk/by-uuid/E820-D6C7"; device = "/dev/disk/by-uuid/E820-D6C7";
fsType = "vfat"; fsType = "vfat";
}; };
swapDevices = [ swapDevices = [
{ device = "/var/swapfile"; size = 32 * 1024; priority = 10; } {
device = "/var/swapfile";
size = 32 * 1024;
priority = 10;
}
]; ];
boot.blacklistedKernelModules = [ boot.blacklistedKernelModules = [

View file

@ -1,9 +1,18 @@
{ nixpkgs, nixpkgs-unstable, ... }@inputs: { nixpkgs, nixpkgs-unstable, ... }@inputs:
let let
overlay-unstable = final: prev: { overlay-unstable = final: prev: {
stable = import nixpkgs { config.allowUnfree = true; system = prev.system; }; stable = import nixpkgs {
unstable = import nixpkgs-unstable { config.allowUnfree = true; system = prev.system; }; config.allowUnfree = true;
x86 = import nixpkgs-unstable { system = prev.system; config.allowUnsupportedSystem = true; }; system = prev.system;
};
unstable = import nixpkgs-unstable {
config.allowUnfree = true;
system = prev.system;
};
x86 = import nixpkgs-unstable {
system = prev.system;
config.allowUnsupportedSystem = true;
};
}; };
overlay-needs-unstable = final: prev: { overlay-needs-unstable = final: prev: {
# Typst updates really quickly. # Typst updates really quickly.
@ -50,8 +59,7 @@ let
input-remapper = final.unstable.input-remapper; input-remapper = final.unstable.input-remapper;
kakoune-unwrapped = kakoune-unwrapped = prev.kakoune-unwrapped.overrideAttrs (attrs: {
prev.kakoune-unwrapped.overrideAttrs (attrs: {
version = "r${builtins.substring 0 6 inputs.kakoune.rev}"; version = "r${builtins.substring 0 6 inputs.kakoune.rev}";
src = inputs.kakoune; src = inputs.kakoune;
patches = [ patches = [
@ -59,9 +67,11 @@ let
]; ];
}); });
librewolf = (prev.librewolf.override { librewolf = (
prev.librewolf.override {
nativeMessagingHosts = with final; [ kdePackages.plasma-browser-integration ]; nativeMessagingHosts = with final; [ kdePackages.plasma-browser-integration ];
}); }
);
vikunja = vikunja =
# builtins.seq # builtins.seq
@ -71,7 +81,9 @@ let
luminance = prev.luminance.overrideAttrs (attrs: { luminance = prev.luminance.overrideAttrs (attrs: {
nativeBuildInputs = attrs.nativeBuildInputs ++ [ final.wrapGAppsHook ]; nativeBuildInputs = attrs.nativeBuildInputs ++ [ final.wrapGAppsHook ];
buildInputs = attrs.buildInputs ++ [ final.glib ]; buildInputs = attrs.buildInputs ++ [ final.glib ];
postInstall = attrs.postInstall + '' postInstall =
attrs.postInstall
+ ''
glib-compile-schemas $out/share/glib-2.0/schemas glib-compile-schemas $out/share/glib-2.0/schemas
''; '';
}); });
@ -79,12 +91,18 @@ let
vesktop = prev.vesktop.overrideAttrs (attrs: { vesktop = prev.vesktop.overrideAttrs (attrs: {
postFixup = postFixup =
let let
flagToReplace = if final.lib.hasInfix "--enable-wayland-ime=true" attrs.postFixup then "--enable-wayland-ime=true" else "--enable-wayland-ime"; flagToReplace =
if final.lib.hasInfix "--enable-wayland-ime=true" attrs.postFixup then
"--enable-wayland-ime=true"
else
"--enable-wayland-ime";
in in
builtins.replaceStrings [ "NIXOS_OZONE_WL" flagToReplace ] [ "WAYLAND_DISPLAY" "${flagToReplace} --wayland-text-input-version=3" ] attrs.postFixup; builtins.replaceStrings
[ "NIXOS_OZONE_WL" flagToReplace ]
[ "WAYLAND_DISPLAY" "${flagToReplace} --wayland-text-input-version=3" ]
attrs.postFixup;
}); });
editline-lix = editline-lix =
assert final.lib.assertMsg (final.lix.version == "2.92.0") "we only need to patch this for 2.92"; assert final.lib.assertMsg (final.lix.version == "2.92.0") "we only need to patch this for 2.92";
final.editline.overrideAttrs (prev: { final.editline.overrideAttrs (prev: {
@ -106,7 +124,9 @@ let
}; };
overlay-packages = final: prev: { overlay-packages = final: prev: {
kak-tree-sitter = final.callPackage ./packages/common/kak-tree-sitter { rustPlatform = final.unstable.rustPlatform; }; kak-tree-sitter = final.callPackage ./packages/common/kak-tree-sitter {
rustPlatform = final.unstable.rustPlatform;
};
kak-lsp = final.unstable.rustPlatform.buildRustPackage { kak-lsp = final.unstable.rustPlatform.buildRustPackage {
name = "kak-lsp"; name = "kak-lsp";
@ -129,9 +149,14 @@ let
zen-browser-bin = inputs.zen-browser.packages.${final.stdenv.system}.zen-browser.override { zen-browser-bin = inputs.zen-browser.packages.${final.stdenv.system}.zen-browser.override {
inherit (inputs.zen-browser.packages.${final.stdenv.system}) zen-browser-unwrapped; inherit (inputs.zen-browser.packages.${final.stdenv.system}) zen-browser-unwrapped;
wrapFirefox = opts: final.wrapFirefox (opts // { wrapFirefox =
opts:
final.wrapFirefox (
opts
// {
nativeMessagingHosts = with final; [ kdePackages.plasma-browser-integration ]; nativeMessagingHosts = with final; [ kdePackages.plasma-browser-integration ];
}); }
);
# zen-browser-unwrapped = final.callPackage inputs.zen-browser.packages.${final.stdenv.system}.zen-browser-unwrapped.override { # zen-browser-unwrapped = final.callPackage inputs.zen-browser.packages.${final.stdenv.system}.zen-browser-unwrapped.override {
# sources = inputs.zen-browser.inputs; # sources = inputs.zen-browser.inputs;
# }; # };

View file

@ -1,4 +1,10 @@
{ pkgs, runCommand, zstd, lib, buildFHSEnvChroot }: {
pkgs,
runCommand,
zstd,
lib,
buildFHSEnvChroot,
}:
let let
typora-tar = builtins.fetchurl { typora-tar = builtins.fetchurl {
@ -13,7 +19,10 @@ let
in in
buildFHSEnvChroot { buildFHSEnvChroot {
name = "typora"; name = "typora";
targetPkgs = pkgs: with pkgs; [ targetPkgs =
pkgs:
with pkgs;
[
glib glib
nss nss
nspr nspr
@ -33,7 +42,8 @@ buildFHSEnvChroot {
wayland wayland
libglvnd libglvnd
electron electron
] ++ (with pkgs.xorg; [ ]
++ (with pkgs.xorg; [
libX11 libX11
libXcomposite libXcomposite
libXdamage libXdamage

View file

@ -1,4 +1,10 @@
{ pkgs, runCommandLocal, zstd, lib, buildFHSEnvChroot }: {
pkgs,
runCommandLocal,
zstd,
lib,
buildFHSEnvChroot,
}:
let let
zotero-tar = builtins.fetchurl { zotero-tar = builtins.fetchurl {
@ -14,7 +20,19 @@ let
in in
buildFHSEnvChroot { buildFHSEnvChroot {
name = "zotero"; name = "zotero";
targetPkgs = pkgs: with pkgs; [ gtk3 dbus-glib libstartup_notification libpaper ] ++ (with pkgs.xorg; [ libX11 libXt ]); targetPkgs =
pkgs:
with pkgs;
[
gtk3
dbus-glib
libstartup_notification
libpaper
]
++ (with pkgs.xorg; [
libX11
libXt
]);
runScript = "env QT_SCALE_FACTOR=2 ${zotero-src}/usr/lib/zotero/zotero"; runScript = "env QT_SCALE_FACTOR=2 ${zotero-src}/usr/lib/zotero/zotero";
extraInstallCommands = '' extraInstallCommands = ''

View file

@ -1,6 +1,6 @@
{ pkgs, runCommand, ... }: runCommand "epfl-cups-drivers" { } '' { pkgs, runCommand, ... }:
runCommand "epfl-cups-drivers" { } ''
mkdir -p $out/share/cups/model mkdir -p $out/share/cups/model
cp ${./PPD-C5860-bw-EN.PPD} $out/share/cups/model cp ${./PPD-C5860-bw-EN.PPD} $out/share/cups/model
cp ${./PPD-C5860-color-EN.PPD} $out/share/cups/model cp ${./PPD-C5860-color-EN.PPD} $out/share/cups/model
'' ''

View file

@ -1,4 +1,13 @@
{ lib, rustPlatform, fetchFromSourcehut, symlinkJoin, clang, git, writeText, ... }: {
lib,
rustPlatform,
fetchFromSourcehut,
symlinkJoin,
clang,
git,
writeText,
...
}:
let let
src = fetchFromSourcehut { src = fetchFromSourcehut {
owner = "~hadronized"; owner = "~hadronized";
@ -12,9 +21,17 @@ let
pname = "kak-tree-sitter"; pname = "kak-tree-sitter";
version = "1.1.3"; version = "1.1.3";
cargoHash = "sha256-1OwPfl1446SYt1556jwR9mvWOWEv+ab+wH7GZQeS4/E="; cargoHash = "sha256-1OwPfl1446SYt1556jwR9mvWOWEv+ab+wH7GZQeS4/E=";
cargoBuildOptions = [ "--package" "kak-tree-sitter" "--package" "ktsctl" ]; cargoBuildOptions = [
"--package"
"kak-tree-sitter"
"--package"
"ktsctl"
];
nativeBuildInputs = [ clang git ]; nativeBuildInputs = [
clang
git
];
patches = [ patches = [
# Allow absolute-path style repos # Allow absolute-path style repos
@ -40,4 +57,3 @@ let
}; };
in in
kak-tree-sitter kak-tree-sitter

View file

@ -1,10 +1,16 @@
{ callPackage, kakoune, kakoune-unwrapped, ... }: {
callPackage,
kakoune,
kakoune-unwrapped,
...
}:
let let
lsp = callPackage ./lsp.nix { }; lsp = callPackage ./lsp.nix { };
rc = (callPackage ./rc.nix { }); rc = (callPackage ./rc.nix { });
in in
(kakoune.override { (kakoune.override {
plugins = callPackage ./plugins.nix { } plugins =
callPackage ./plugins.nix { }
++ callPackage ./themes.nix { } ++ callPackage ./themes.nix { }
++ [ ++ [
(callPackage ./kaktex { }) (callPackage ./kaktex { })
@ -12,7 +18,8 @@ in
rc rc
lsp.plugin lsp.plugin
]; ];
}).overrideAttrs (attrs: { }).overrideAttrs
(attrs: {
buildCommand = '' buildCommand = ''
${attrs.buildCommand or ""} ${attrs.buildCommand or ""}
# location of kak binary is used to find ../share/kak/autoload, # location of kak binary is used to find ../share/kak/autoload,

View file

@ -28,4 +28,5 @@ faces = {
mutable_variable = "+i@variable"; mutable_variable = "+i@variable";
class = "+b@variable"; class = "+b@variable";
}; };
in utils.mkFacesScript "default-faces" faces in
utils.mkFacesScript "default-faces" faces

Some files were not shown because too many files have changed in this diff Show more