Compare commits

..

18 commits

Author SHA1 Message Date
2c0062bf51 flake: home-manager: export NixOS homes
All checks were successful
ci/woodpecker/push/check Pipeline was successful
And here is what the last few commits were building up to.

This is neat, but won't be useful *very* often.
2025-07-07 15:08:04 +00:00
31effae175 flake: home-manager: refactor 'mkHome'
This will allow making a similar function for NixOS homes.
2025-07-07 15:08:04 +00:00
87ba726b18 flake: home-manager: use 'hosts' option 2025-07-07 15:08:04 +00:00
9e35764e0c flake: nixos: use 'hosts' option 2025-07-07 15:08:04 +00:00
1c86c85c56 flake: add hosts
This will allow other modules to cross-reference which hosts exist on
which system.

My main use-case is to automatically declare home-manager configuration
for the home configuration of NixOS hosts.

I also include Darwin in case I ever want to use that in the future,
though that is unlikely for the moment.
2025-07-07 15:08:04 +00:00
7ac78ca260 hosts: nixos: porthos: add profiles 2025-07-07 15:08:04 +00:00
d181f3a719 common: profiles: forward profiles to home-manager
We can only do this now that every profile has been migrated, otherwise
we would get errors about undeclared modules... It's not perfect, but
it's good enough.
2025-07-07 15:08:04 +00:00
2a6696bafc common: profiles: migrate X 2025-07-07 15:08:03 +00:00
75f1776916 common: profiles: migrate wm 2025-07-07 15:08:03 +00:00
b1be9f20d9 common: profiles: migrate laptop 2025-07-07 15:08:03 +00:00
a68c26c6ef common: profiles: migrate gtk 2025-07-07 15:08:03 +00:00
9ee0cb3287 common: profiles: migrate devices 2025-07-07 15:08:03 +00:00
e01c8330d6 common: profiles: migrate bluetooth 2025-07-07 15:08:03 +00:00
033b0e8a57 common: add profiles
I will be migrating each sub-module one by one.
2025-07-07 15:08:03 +00:00
27a486bf5c flake: nixos: import common modules 2025-07-07 15:08:03 +00:00
5d706dd2dc flake: home-manager: import common modules 2025-07-07 15:08:03 +00:00
748e55f1a6 nixos: home: import common modules 2025-07-07 15:08:03 +00:00
2ed60a227e modules: add common
This should define modules that are identical, or very similar.

The driving force is to be able to use `my.profiles` on home-manager and NixOS
without repeating myself.

In the future I might migrate other modules, such as `nixos/system/nix`...
2025-07-07 15:08:02 +00:00
60 changed files with 664 additions and 646 deletions

68
flake.lock generated
View file

@ -14,11 +14,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1762618334, "lastModified": 1750173260,
"narHash": "sha256-wyT7Pl6tMFbFrs8Lk/TlEs81N6L+VSybPfiIgzU8lbQ=", "narHash": "sha256-9P1FziAwl5+3edkfFcr5HeGtQUtrSdk/MksX39GieoA=",
"owner": "ryantm", "owner": "ryantm",
"repo": "agenix", "repo": "agenix",
"rev": "fcdea223397448d35d9b31f798479227e80183f6", "rev": "531beac616433bac6f9e2a19feb8e99a22a66baf",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -53,11 +53,11 @@
"flake-compat": { "flake-compat": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1761588595, "lastModified": 1696426674,
"narHash": "sha256-XKUZz9zewJNUj46b4AJdiRZJAvSZ0Dqj2BNfXvFlJC4=", "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra", "owner": "edolstra",
"repo": "flake-compat", "repo": "flake-compat",
"rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5", "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -73,11 +73,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1765835352, "lastModified": 1751413152,
"narHash": "sha256-XswHlK/Qtjasvhd1nOa1e8MgZ8GS//jBoTqWtrS1Giw=", "narHash": "sha256-Tyw1RjYEsp5scoigs1384gIg6e0GoBVjms4aXFfRssQ=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "a34fae9c08a15ad73f295041fec82323541400a9", "rev": "77826244401ea9de6e3bac47c2db46005e1f30b5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -117,11 +117,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1765911976, "lastModified": 1750779888,
"narHash": "sha256-t3T/xm8zstHRLx+pIHxVpQTiySbKqcQbK+r+01XVKc0=", "narHash": "sha256-wibppH3g/E2lxU43ZQHC5yA/7kIKLGxVEnsnVK1BtRg=",
"owner": "cachix", "owner": "cachix",
"repo": "git-hooks.nix", "repo": "git-hooks.nix",
"rev": "b68b780b69702a090c8bb1b973bab13756cc7a27", "rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -159,11 +159,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1766171975, "lastModified": 1751429452,
"narHash": "sha256-47Ee0bTidhF/3/sHuYnWRuxcCrrm0mBNDxBkOTd3wWQ=", "narHash": "sha256-4s5vRtaqdNhVBnbOWOzBNKrRa0ShQTLoEPjJp3joeNI=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "bb35f07cc95a73aacbaf1f7f46bb8a3f40f265b5", "rev": "df12269039dcf752600b1bcc176bacf2786ec384",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -175,11 +175,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1766070988, "lastModified": 1751271578,
"narHash": "sha256-G/WVghka6c4bAzMhTwT2vjLccg/awmHkdKSd2JrycLc=", "narHash": "sha256-P/SQmKDu06x8yv7i0s8bvnnuJYkxVGBWLWHaU+tt4YY=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "c6245e83d836d0433170a16eb185cefe0572f8b8", "rev": "3016b4b15d13f3089db8a41ef937b13a9e33a8df",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -196,19 +196,20 @@
], ],
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ],
"treefmt-nix": "treefmt-nix"
}, },
"locked": { "locked": {
"lastModified": 1766242030, "lastModified": 1741294988,
"narHash": "sha256-GdaKIZrzm4fbFf9jBVmeQFZTwYPxUlSTZrSId/JNMAU=", "narHash": "sha256-3408u6q615kVTb23WtDriHRmCBBpwX7iau6rvfipcu4=",
"owner": "nix-community", "owner": "nix-community",
"repo": "NUR", "repo": "NUR",
"rev": "30006228925f07c5c2a270bb95dc8da35d9942dc", "rev": "b30c245e2c44c7352a27485bfd5bc483df660f0e",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nix-community", "owner": "nix-community",
"ref": "main", "ref": "master",
"repo": "NUR", "repo": "NUR",
"type": "github" "type": "github"
} }
@ -240,6 +241,27 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nur",
"nixpkgs"
]
},
"locked": {
"lastModified": 1733222881,
"narHash": "sha256-JIPcz1PrpXUCbaccEnrcUS8jjEb/1vJbZz5KkobyFdM=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "49717b5af6f80172275d47a418c9719a31a78b53",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -54,7 +54,7 @@
type = "github"; type = "github";
owner = "nix-community"; owner = "nix-community";
repo = "NUR"; repo = "NUR";
ref = "main"; ref = "master";
inputs = { inputs = {
flake-parts.follows = "flake-parts"; flake-parts.follows = "flake-parts";
nixpkgs.follows = "nixpkgs"; nixpkgs.follows = "nixpkgs";

View file

@ -13,6 +13,7 @@ flake-parts.lib.mkFlake { inherit inputs; } {
./checks.nix ./checks.nix
./dev-shells.nix ./dev-shells.nix
./home-manager.nix ./home-manager.nix
./hosts.nix
./lib.nix ./lib.nix
./nixos.nix ./nixos.nix
./overlays.nix ./overlays.nix

View file

@ -1,5 +1,7 @@
{ self, inputs, lib, ... }: { self, config, inputs, lib, ... }:
let let
inherit (config) hosts;
defaultModules = [ defaultModules = [
# Include generic settings # Include generic settings
"${self}/modules/home" "${self}/modules/home"
@ -19,14 +21,14 @@ let
# Enable home-manager # Enable home-manager
programs.home-manager.enable = true; programs.home-manager.enable = true;
} }
# Import common modules
"${self}/modules/common"
]; ];
mkHome = name: system: inputs.home-manager.lib.homeManagerConfiguration { mkHomeCommon = mainModules: system: inputs.home-manager.lib.homeManagerConfiguration {
pkgs = inputs.nixpkgs.legacyPackages.${system}; pkgs = inputs.nixpkgs.legacyPackages.${system};
modules = defaultModules ++ [ modules = defaultModules ++ mainModules;
"${self}/hosts/homes/${name}"
];
# Use my extended lib in NixOS configuration # Use my extended lib in NixOS configuration
inherit (self) lib; inherit (self) lib;
@ -37,24 +39,41 @@ let
}; };
}; };
homes = { mkHome = name: mkHomeCommon [ "${self}/hosts/homes/${name}" ];
mkNixosHome = name: mkHomeCommon [
"${self}/hosts/nixos/${name}/home.nix"
"${self}/hosts/nixos/${name}/profiles.nix"
];
in
{
hosts.homes = {
"ambroisie@bazin" = "x86_64-linux"; "ambroisie@bazin" = "x86_64-linux";
"ambroisie@mousqueton" = "x86_64-linux"; "ambroisie@mousqueton" = "x86_64-linux";
}; };
in
{
perSystem = { system, ... }: { perSystem = { system, ... }: {
# Work-around for https://github.com/nix-community/home-manager/issues/3075 # Work-around for https://github.com/nix-community/home-manager/issues/3075
legacyPackages = { legacyPackages = {
homeConfigurations = homeConfigurations =
let let
filteredHomes = lib.filterAttrs (_: v: v == system) homes; filteredHomes = lib.filterAttrs (_: v: v == system) hosts.homes;
allHomes = filteredHomes // { allHomes = filteredHomes // {
# Default configuration # Default configuration
ambroisie = system; ambroisie = system;
}; };
homeManagerHomes = lib.mapAttrs mkHome allHomes;
filteredNixosHosts = lib.filterAttrs (_: v: v == system) hosts.nixos;
nixosHomes' = lib.mapAttrs mkNixosHome filteredNixosHosts;
nixosHomeUsername = (host: self.nixosConfigurations.${host}.config.my.user.name);
nixosHomes = lib.mapAttrs' (host: lib.nameValuePair "${nixosHomeUsername host}@${host}") nixosHomes';
in in
lib.mapAttrs mkHome allHomes; lib.foldl' lib.mergeAttrs { }
[
homeManagerHomes
nixosHomes
];
}; };
}; };
} }

21
flake/hosts.nix Normal file
View file

@ -0,0 +1,21 @@
# Define `hosts.{darwin,home,nixos}` options for consumption in other modules
{ lib, ... }:
let
mkHostsOption = description: lib.mkOption {
inherit description;
type = with lib.types; attrsOf str;
default = { };
example = { name = "x86_64-linux"; };
};
in
{
options = {
hosts = {
darwin = mkHostsOption "Darwin hosts";
homes = mkHostsOption "Home Manager hosts";
nixos = mkHostsOption "NixOS hosts";
};
};
}

View file

@ -1,4 +1,4 @@
{ self, inputs, lib, ... }: { self, config, inputs, lib, ... }:
let let
defaultModules = [ defaultModules = [
{ {
@ -12,6 +12,8 @@ let
} }
# Include generic settings # Include generic settings
"${self}/modules/nixos" "${self}/modules/nixos"
# Import common modules
"${self}/modules/common"
]; ];
buildHost = name: system: lib.nixosSystem { buildHost = name: system: lib.nixosSystem {
@ -30,8 +32,12 @@ let
}; };
in in
{ {
flake.nixosConfigurations = lib.mapAttrs buildHost { config = {
aramis = "x86_64-linux"; hosts.nixos = {
porthos = "x86_64-linux"; aramis = "x86_64-linux";
porthos = "x86_64-linux";
};
flake.nixosConfigurations = lib.mapAttrs buildHost config.hosts.nixos;
}; };
} }

View file

@ -1,4 +1,4 @@
{ self, lib, ... }: { self, ... }:
let let
default-overlays = import "${self}/overlays"; default-overlays = import "${self}/overlays";
@ -8,7 +8,7 @@ let
# Expose my custom packages # Expose my custom packages
pkgs = _final: prev: { pkgs = _final: prev: {
ambroisie = lib.recurseIntoAttrs (import "${self}/pkgs" { pkgs = prev; }); ambroisie = prev.recurseIntoAttrs (import "${self}/pkgs" { pkgs = prev; });
}; };
}; };
in in

View file

@ -18,7 +18,9 @@
# Machine specific packages # Machine specific packages
packages.additionalPackages = with pkgs; [ packages.additionalPackages = with pkgs; [
element-desktop # Matrix client element-desktop # Matrix client
jellyfin-media-player # Wraps the webui and mpv together
pavucontrol # Audio mixer GUI pavucontrol # Audio mixer GUI
trgui-ng # Transmission remote
]; ];
# Minimal video player # Minimal video player
mpv.enable = true; mpv.enable = true;
@ -26,8 +28,6 @@
nm-applet.enable = true; nm-applet.enable = true;
# Terminal # Terminal
terminal.program = "alacritty"; terminal.program = "alacritty";
# Transmission remote
trgui.enable = true;
# Zathura document viewer # Zathura document viewer
zathura.enable = true; zathura.enable = true;
}; };

View file

@ -7,6 +7,7 @@
./hardware.nix ./hardware.nix
./home.nix ./home.nix
./networking.nix ./networking.nix
./profiles.nix
./secrets ./secrets
./services.nix ./services.nix
./system.nix ./system.nix

View file

@ -0,0 +1,4 @@
{ ... }:
{
# Nothing
}

View file

@ -83,9 +83,18 @@ in
"servarr/autobrr/session-secret.age".publicKeys = all; "servarr/autobrr/session-secret.age".publicKeys = all;
"servarr/cross-seed/configuration.json.age".publicKeys = all; "servarr/cross-seed/configuration.json.age".publicKeys = all;
"sso/auth-key.age".publicKeys = all; "sso/auth-key.age" = {
"sso/ambroisie/password-hash.age".publicKeys = all; owner = "nginx-sso";
"sso/ambroisie/totp-secret.age".publicKeys = all; publicKeys = all;
};
"sso/ambroisie/password-hash.age" = {
owner = "nginx-sso";
publicKeys = all;
};
"sso/ambroisie/totp-secret.age" = {
owner = "nginx-sso";
publicKeys = all;
};
"tandoor-recipes/secret-key.age".publicKeys = all; "tandoor-recipes/secret-key.age".publicKeys = all;

View file

@ -0,0 +1,28 @@
# Modules that are common to various module systems
# Usually with very small differences, if any, between them.
{ lib, _class, ... }:
let
allowedClass = [
"darwin"
"homeManager"
"nixos"
];
allowedClassString = lib.concatStringSep ", " (builtins.map lib.escapeNixString allowedClass);
in
{
imports = [
./profiles
];
config = {
assertions = [
{
assertion = builtins.elem _class allowedClass;
message = ''
`_class` specialArgs must be one of ${allowedClassString}.
'';
}
];
};
}

View file

@ -0,0 +1,19 @@
{ config, lib, _class, ... }:
let
cfg = config.my.profiles.bluetooth;
in
{
options.my.profiles.bluetooth = with lib; {
enable = mkEnableOption "bluetooth profile";
};
config = lib.mkIf cfg.enable (lib.mkMerge [
(lib.optionalAttrs (_class == "homeManager") {
my.home.bluetooth.enable = true;
})
(lib.optionalAttrs (_class == "nixos") {
my.hardware.bluetooth.enable = true;
})
]);
}

View file

@ -0,0 +1,25 @@
# Configuration that spans across system and home, or are almagations of modules
{ config, lib, _class, ... }:
{
imports = [
./bluetooth
./devices
./gtk
./laptop
./wm
./x
];
config = lib.mkMerge [
# Transparently enable home-manager profiles as well
(lib.optionalAttrs (_class != "homeManager") {
home-manager.users.${config.my.user.name} = {
config = {
my = {
inherit (config.my) profiles;
};
};
};
})
];
}

View file

@ -0,0 +1,22 @@
{ config, lib, _class, ... }:
let
cfg = config.my.profiles.devices;
in
{
options.my.profiles.devices = with lib; {
enable = mkEnableOption "devices profile";
};
config = lib.mkIf cfg.enable (lib.mkMerge [
(lib.optionalAttrs (_class == "nixos") {
my.hardware = {
ergodox.enable = true;
trackball.enable = true;
};
# MTP devices auto-mount via file explorers
services.gvfs.enable = true;
})
]);
}

View file

@ -0,0 +1,21 @@
{ config, lib, _class, ... }:
let
cfg = config.my.profiles.gtk;
in
{
options.my.profiles.gtk = with lib; {
enable = mkEnableOption "gtk profile";
};
config = lib.mkIf cfg.enable (lib.mkMerge [
(lib.optionalAttrs (_class == "homeManager") {
# GTK theme configuration
my.home.gtk.enable = true;
})
(lib.optionalAttrs (_class == "nixos") {
# Allow setting GTK configuration using home-manager
programs.dconf.enable = true;
})
]);
}

View file

@ -0,0 +1,27 @@
{ config, lib, _class, ... }:
let
cfg = config.my.profiles.laptop;
in
{
options.my.profiles.laptop = with lib; {
enable = mkEnableOption "laptop profile";
};
config = lib.mkIf cfg.enable (lib.mkMerge [
(lib.optionalAttrs (_class == "homeManager") {
# Enable battery notifications
my.home.power-alert.enable = true;
})
(lib.optionalAttrs (_class == "nixos") {
# Enable touchpad support
services.libinput.enable = true;
# Enable TLP power management
my.services.tlp.enable = true;
# Enable upower power management
my.hardware.upower.enable = true;
})
]);
}

View file

@ -0,0 +1,38 @@
{ config, lib, _class, ... }:
let
cfg = config.my.profiles.wm;
applyWm = wm: configs: lib.mkIf (cfg.windowManager == wm) (lib.my.merge configs);
in
{
options.my.profiles.wm = with lib; {
windowManager = mkOption {
type = with types; nullOr (enum [ "i3" ]);
default = null;
example = "i3";
description = "Which window manager to use";
};
};
config = lib.mkMerge [
(applyWm "i3" [
(lib.optionalAttrs (_class == "homeManager") {
# i3 settings
my.home.wm.windowManager = "i3";
# Screenshot tool
my.home.flameshot.enable = true;
# Auto disk mounter
my.home.udiskie.enable = true;
})
(lib.optionalAttrs (_class == "nixos") {
# Enable i3
services.xserver.windowManager.i3.enable = true;
# udiskie fails if it can't find this dbus service
services.udisks2.enable = true;
# Ensure i3lock can actually unlock the session
security.pam.services.i3lock.enable = true;
})
])
];
}

View file

@ -0,0 +1,27 @@
{ config, lib, pkgs, _class, ... }:
let
cfg = config.my.profiles.x;
in
{
options.my.profiles.x = with lib; {
enable = mkEnableOption "X profile";
};
config = lib.mkIf cfg.enable (lib.mkMerge [
(lib.optionalAttrs (_class == "homeManager") {
# X configuration
my.home.x.enable = true;
})
(lib.optionalAttrs (_class == "nixos") {
# Enable the X11 windowing system.
services.xserver.enable = true;
# Nice wallpaper
services.xserver.displayManager.lightdm.background =
let
wallpapers = "${pkgs.plasma5Packages.plasma-workspace-wallpapers}/share/wallpapers";
in
"${wallpapers}/summer_1am/contents/images/2560x1600.jpg";
})
]);
}

View file

@ -6,6 +6,7 @@ in
options.my.home.atuin = with lib; { options.my.home.atuin = with lib; {
enable = my.mkDisableOption "atuin configuration"; enable = my.mkDisableOption "atuin configuration";
# I want the full experience by default
package = mkPackageOption pkgs "atuin" { }; package = mkPackageOption pkgs "atuin" { };
daemon = { daemon = {

View file

@ -38,7 +38,6 @@
./ssh ./ssh
./terminal ./terminal
./tmux ./tmux
./trgui
./udiskie ./udiskie
./vim ./vim
./wget ./wget

View file

@ -14,34 +14,53 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.delta = { assertions = [
enable = true; {
# For its configuration
assertion = cfg.enable -> cfg.git.enable;
message = ''
`config.my.home.delta` must enable `config.my.home.delta.git` to be
properly configured.
'';
}
{
assertion = cfg.enable -> config.programs.git.enable;
message = ''
`config.my.home.delta` relies on `config.programs.git` to be
enabled.
'';
}
];
inherit (cfg) package; home.packages = [ cfg.package ];
enableGitIntegration = cfg.git.enable; programs.git = lib.mkIf cfg.git.enable {
delta = {
enable = true;
inherit (cfg) package;
options = { options = {
features = "diff-highlight decorations"; features = "diff-highlight decorations";
# Less jarring style for `diff-highlight` emulation # Less jarring style for `diff-highlight` emulation
diff-highlight = { diff-highlight = {
minus-style = "red"; minus-style = "red";
minus-non-emph-style = "red"; minus-non-emph-style = "red";
minus-emph-style = "bold red 52"; minus-emph-style = "bold red 52";
plus-style = "green"; plus-style = "green";
plus-non-emph-style = "green"; plus-non-emph-style = "green";
plus-emph-style = "bold green 22"; plus-emph-style = "bold green 22";
whitespace-error-style = "reverse red"; whitespace-error-style = "reverse red";
}; };
# Personal preference for easier reading # Personal preference for easier reading
decorations = { decorations = {
commit-style = "raw"; # Do not recolor meta information commit-style = "raw"; # Do not recolor meta information
keep-plus-minus-markers = true; keep-plus-minus-markers = true;
paging = "always"; paging = "always";
};
}; };
}; };
}; };

View file

@ -1,6 +1,8 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
cfg = config.my.home.discord; cfg = config.my.home.discord;
jsonFormat = pkgs.formats.json { };
in in
{ {
options.my.home.discord = with lib; { options.my.home.discord = with lib; {
@ -10,15 +12,14 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.discord = { home.packages = with pkgs; [
enable = true; cfg.package
];
inherit (cfg) package; xdg.configFile."discord/settings.json".source =
jsonFormat.generate "discord.json" {
settings = {
# Do not keep me from using the app just to force an update # Do not keep me from using the app just to force an update
SKIP_HOST_UPDATE = true; SKIP_HOST_UPDATE = true;
}; };
};
}; };
} }

View file

@ -52,7 +52,6 @@ in
"browser.newtabpage.activity-stream.feeds.sections" = false; "browser.newtabpage.activity-stream.feeds.sections" = false;
"browser.newtabpage.activity-stream.feeds.system.topstories" = false; # Disable top stories "browser.newtabpage.activity-stream.feeds.system.topstories" = false; # Disable top stories
"browser.newtabpage.activity-stream.section.highlights.includePocket" = false; # Disable pocket "browser.newtabpage.activity-stream.section.highlights.includePocket" = false; # Disable pocket
"browser.urlbar.trimURLs" = false; # Always show the `http://` prefix
"extensions.pocket.enabled" = false; # Disable pocket "extensions.pocket.enabled" = false; # Disable pocket
"media.eme.enabled" = true; # Enable DRM "media.eme.enabled" = true; # Enable DRM
"media.gmp-widevinecdm.enabled" = true; # Enable DRM "media.gmp-widevinecdm.enabled" = true; # Enable DRM

View file

@ -21,31 +21,29 @@ in
config.programs.git = lib.mkIf cfg.enable { config.programs.git = lib.mkIf cfg.enable {
enable = true; enable = true;
# Who am I?
userEmail = mkMailAddress "bruno" "belanyi.fr";
userName = "Bruno BELANYI";
inherit (cfg) package; inherit (cfg) package;
aliases = {
git = "!git";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit --topo-order";
lola = "lol --all";
assume = "update-index --assume-unchanged";
unassume = "update-index --no-assume-unchanged";
assumed = "!git ls-files -v | grep ^h | cut -c 3-";
pick = "log -p -G";
push-new = "!git push -u origin "
+ ''"$(git branch | grep '^* ' | cut -f2- -d' ')"'';
root = "git rev-parse --show-toplevel";
};
lfs.enable = true; lfs.enable = true;
# There's more # There's more
settings = { extraConfig = {
# Who am I?
user = {
email = mkMailAddress "bruno" "belanyi.fr";
name = "Bruno BELANYI";
};
alias = {
git = "!git";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit --topo-order";
lola = "lol --all";
assume = "update-index --assume-unchanged";
unassume = "update-index --no-assume-unchanged";
assumed = "!git ls-files -v | grep ^h | cut -c 3-";
pick = "log -p -G";
push-new = "!git push -u origin "
+ ''"$(git branch | grep '^* ' | cut -f2- -d' ')"'';
root = "git rev-parse --show-toplevel";
};
# Makes it a bit more readable # Makes it a bit more readable
blame = { blame = {
coloring = "repeatedLines"; coloring = "repeatedLines";

View file

@ -69,7 +69,7 @@ in
automatic = true; automatic = true;
# Every week, with some wiggle room # Every week, with some wiggle room
dates = "weekly"; frequency = "weekly";
randomizedDelaySec = "10min"; randomizedDelaySec = "10min";
# Use a persistent timer for e.g: laptops # Use a persistent timer for e.g: laptops

View file

@ -17,7 +17,6 @@ in
{ {
programs.ssh = { programs.ssh = {
enable = true; enable = true;
enableDefaultConfig = false;
includes = [ includes = [
# Local configuration, not-versioned # Local configuration, not-versioned
@ -54,12 +53,11 @@ in
identityFile = "~/.ssh/shared_rsa"; identityFile = "~/.ssh/shared_rsa";
user = "ambroisie"; user = "ambroisie";
}; };
# `*` is automatically made the last match block by the module
"*" = {
addKeysToAgent = "yes";
};
}; };
extraConfig = ''
AddKeysToAgent yes
'';
}; };
} }

View file

@ -48,7 +48,7 @@ in
keyMode = "vi"; # Home-row keys and other niceties keyMode = "vi"; # Home-row keys and other niceties
clock24 = true; # I'm one of those heathens clock24 = true; # I'm one of those heathens
escapeTime = 0; # Let vim do its thing instead escapeTime = 0; # Let vim do its thing instead
historyLimit = 1000000; # Bigger buffer historyLimit = 100000; # Bigger buffer
mouse = false; # I dislike mouse support mouse = false; # I dislike mouse support
focusEvents = true; # Report focus events focusEvents = true; # Report focus events
terminal = "tmux-256color"; # I want accurate termcap info terminal = "tmux-256color"; # I want accurate termcap info
@ -61,8 +61,8 @@ in
pain-control pain-control
# Better session management # Better session management
sessionist sessionist
# X clipboard integration
{ {
# X clipboard integration
plugin = yank; plugin = yank;
extraConfig = '' extraConfig = ''
# Use 'clipboard' because of misbehaving apps (e.g: firefox) # Use 'clipboard' because of misbehaving apps (e.g: firefox)
@ -71,8 +71,8 @@ in
set -g @yank_action 'copy-pipe' set -g @yank_action 'copy-pipe'
''; '';
} }
# Show when prefix has been pressed
{ {
# Show when prefix has been pressed
plugin = prefix-highlight; plugin = prefix-highlight;
extraConfig = '' extraConfig = ''
# Also show when I'm in copy or sync mode # Also show when I'm in copy or sync mode

View file

@ -1,17 +0,0 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.trgui;
in
{
options.my.home.trgui = with lib; {
enable = mkEnableOption "Transmission GUI onfiguration";
package = mkPackageOption pkgs "TrguiNG" { default = "trgui-ng"; };
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
cfg.package
];
};
}

View file

@ -80,6 +80,7 @@ in
nvim-surround # Deal with pairs, now in Lua nvim-surround # Deal with pairs, now in Lua
oil-nvim # Better alternative to NetrW oil-nvim # Better alternative to NetrW
telescope-fzf-native-nvim # Use 'fzf' fuzzy matching algorithm telescope-fzf-native-nvim # Use 'fzf' fuzzy matching algorithm
telescope-lsp-handlers-nvim # Use 'telescope' for various LSP actions
telescope-nvim # Fuzzy finder interface telescope-nvim # Fuzzy finder interface
which-key-nvim # Show available mappings which-key-nvim # Show available mappings
]; ];

View file

@ -0,0 +1,7 @@
-- Use GLSL filetype for common shader file extensions
vim.filetype.add({
extension = {
frag = "glsl",
vert = "glsl",
},
})

View file

@ -81,6 +81,9 @@ set updatetime=250
" Disable all mouse integrations " Disable all mouse integrations
set mouse= set mouse=
" Set dark mode by default
set background=dark
" Setup some overrides for gruvbox " Setup some overrides for gruvbox
lua << EOF lua << EOF
local gruvbox = require("gruvbox") local gruvbox = require("gruvbox")

View file

@ -1,3 +1,4 @@
local lspconfig = require("lspconfig")
local lsp = require("ambroisie.lsp") local lsp = require("ambroisie.lsp")
local utils = require("ambroisie.utils") local utils = require("ambroisie.utils")
@ -24,27 +25,59 @@ vim.diagnostic.config({
-- Inform servers we are able to do completion, snippets, etc... -- Inform servers we are able to do completion, snippets, etc...
local capabilities = require("cmp_nvim_lsp").default_capabilities() local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Shared configuration -- C/C++
vim.lsp.config("*", { if utils.is_executable("clangd") then
capabilities = capabilities, lspconfig.clangd.setup({
on_attach = lsp.on_attach, capabilities = capabilities,
}) on_attach = lsp.on_attach,
})
end
local servers = { -- Haskell
-- C/C++ if utils.is_executable("haskell-language-server-wrapper") then
clangd = {}, lspconfig.hls.setup({
-- Haskell capabilities = capabilities,
hls = {}, on_attach = lsp.on_attach,
-- Nix })
nil_ls = {}, end
-- Python
pyright = {}, -- Nix
ruff = {}, if utils.is_executable("nil") then
-- Rust lspconfig.nil_ls.setup({
rust_analyzer = {}, capabilities = capabilities,
-- Shell on_attach = lsp.on_attach,
bashls = { })
end
-- Python
if utils.is_executable("pyright") then
lspconfig.pyright.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end
if utils.is_executable("ruff") then
lspconfig.ruff.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end
-- Rust
if utils.is_executable("rust-analyzer") then
lspconfig.rust_analyzer.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end
-- Shell
if utils.is_executable("bash-language-server") then
lspconfig.bashls.setup({
filetypes = { "bash", "sh", "zsh" }, filetypes = { "bash", "sh", "zsh" },
capabilities = capabilities,
on_attach = lsp.on_attach,
settings = { settings = {
bashIde = { bashIde = {
shfmt = { shfmt = {
@ -55,17 +88,28 @@ local servers = {
}, },
}, },
}, },
}, })
-- Starlark end
starpls = {},
-- Generic -- Starlark
harper_ls = {}, if utils.is_executable("starpls") then
typos_lsp = {}, lspconfig.starpls.setup({
} capabilities = capabilities,
on_attach = lsp.on_attach,
for server, config in pairs(servers) do })
if not vim.tbl_isempty(config) then end
vim.lsp.config(server, config)
end -- Generic
vim.lsp.enable(server) if utils.is_executable("harper-ls") then
lspconfig.harper_ls.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end
if utils.is_executable("typos-lsp") then
lspconfig.typos_lsp.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end end

View file

@ -23,6 +23,7 @@ telescope.setup({
}) })
telescope.load_extension("fzf") telescope.load_extension("fzf")
telescope.load_extension("lsp_handlers")
local keys = { local keys = {
{ "<leader>f", group = "Fuzzy finder" }, { "<leader>f", group = "Fuzzy finder" },

View file

@ -56,7 +56,4 @@ in
XCOMPOSECACHE = "${dataHome}/X11/xcompose"; XCOMPOSECACHE = "${dataHome}/X11/xcompose";
_JAVA_OPTIONS = "-Djava.util.prefs.userRoot=${configHome}/java"; _JAVA_OPTIONS = "-Djava.util.prefs.userRoot=${configHome}/java";
}; };
# Some modules *optionally* use `XDG_*_HOME` when told to
config.home.preferXdgDirectories = lib.mkIf cfg.enable true;
} }

View file

@ -1,6 +1,14 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
cfg = config.my.home.zsh; cfg = config.my.home.zsh;
# Have a nice relative path for XDG_CONFIG_HOME, without leading `/`
relativeXdgConfig =
let
noHome = lib.removePrefix config.home.homeDirectory;
noSlash = lib.removePrefix "/";
in
noSlash (noHome config.xdg.configHome);
in in
{ {
options.my.home.zsh = with lib; { options.my.home.zsh = with lib; {
@ -8,22 +16,16 @@ in
launchTmux = mkEnableOption "auto launch tmux at shell start"; launchTmux = mkEnableOption "auto launch tmux at shell start";
completionSync = {
enable = mkEnableOption "zsh-completion-sync plugin";
};
notify = { notify = {
enable = mkEnableOption "zsh-done notification"; enable = mkEnableOption "zsh-done notification";
exclude = mkOption { exclude = mkOption {
type = with types; listOf str; type = with types; listOf str;
default = [ default = [
"bat"
"delta" "delta"
"direnv reload" "direnv reload"
"fg" "fg"
"git (?!push|pull|fetch)" "git (?!push|pull|fetch)"
"home-manager (?!switch|build)"
"htop" "htop"
"less" "less"
"man" "man"
@ -55,7 +57,7 @@ in
programs.zsh = { programs.zsh = {
enable = true; enable = true;
dotDir = "${config.xdg.configHome}/zsh"; # Don't clutter $HOME dotDir = "${relativeXdgConfig}/zsh"; # Don't clutter $HOME
enableCompletion = true; enableCompletion = true;
history = { history = {
@ -72,7 +74,7 @@ in
plugins = [ plugins = [
{ {
name = "fast-syntax-highlighting"; name = "fast-syntax-highlighting";
file = "share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh"; file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
src = pkgs.zsh-fast-syntax-highlighting; src = pkgs.zsh-fast-syntax-highlighting;
} }
{ {
@ -122,18 +124,6 @@ in
}; };
} }
(lib.mkIf cfg.completionSync.enable {
programs.zsh = {
plugins = [
{
name = "zsh-completion-sync";
file = "share/zsh-completion-sync/zsh-completion-sync.plugin.zsh";
src = pkgs.zsh-completion-sync;
}
];
};
})
(lib.mkIf cfg.notify.enable { (lib.mkIf cfg.notify.enable {
programs.zsh = { programs.zsh = {
plugins = [ plugins = [

View file

@ -5,7 +5,6 @@
imports = [ imports = [
./hardware ./hardware
./home ./home
./profiles
./programs ./programs
./secrets ./secrets
./services ./services

View file

@ -15,6 +15,8 @@ in
amd = { amd = {
enableKernelModule = lib.my.mkDisableOption "Kernel driver module"; enableKernelModule = lib.my.mkDisableOption "Kernel driver module";
amdvlk = lib.mkEnableOption "Use AMDVLK instead of Mesa RADV driver";
}; };
intel = { intel = {
@ -33,6 +35,13 @@ in
(lib.mkIf (cfg.gpuFlavor == "amd") { (lib.mkIf (cfg.gpuFlavor == "amd") {
hardware.amdgpu = { hardware.amdgpu = {
initrd.enable = cfg.amd.enableKernelModule; initrd.enable = cfg.amd.enableKernelModule;
# Vulkan
amdvlk = lib.mkIf cfg.amd.amdvlk {
enable = true;
support32Bit = {
enable = true;
};
};
}; };
hardware.graphics = { hardware.graphics = {

View file

@ -13,8 +13,13 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home-manager = { home-manager = {
# Not a fan of out-of-directory imports, but this is a good exception users.${config.my.user.name} = {
users.${config.my.user.name} = import "${inputs.self}/modules/home"; # Not a fan of out-of-directory imports, but this is a good exception
imports = [
"${inputs.self}/modules/common"
"${inputs.self}/modules/home"
];
};
# Nix Flakes compatibility # Nix Flakes compatibility
useGlobalPkgs = true; useGlobalPkgs = true;

View file

@ -1,15 +0,0 @@
{ config, lib, ... }:
let
cfg = config.my.profiles.bluetooth;
in
{
options.my.profiles.bluetooth = with lib; {
enable = mkEnableOption "bluetooth profile";
};
config = lib.mkIf cfg.enable {
my.hardware.bluetooth.enable = true;
my.home.bluetooth.enable = true;
};
}

View file

@ -1,12 +0,0 @@
# Configuration that spans across system and home, or are almagations of modules
{ ... }:
{
imports = [
./bluetooth
./devices
./gtk
./laptop
./wm
./x
];
}

View file

@ -1,20 +0,0 @@
{ config, lib, ... }:
let
cfg = config.my.profiles.devices;
in
{
options.my.profiles.devices = with lib; {
enable = mkEnableOption "devices profile";
};
config = lib.mkIf cfg.enable {
my.hardware = {
ergodox.enable = true;
trackball.enable = true;
};
# MTP devices auto-mount via file explorers
services.gvfs.enable = true;
};
}

View file

@ -1,17 +0,0 @@
{ config, lib, ... }:
let
cfg = config.my.profiles.gtk;
in
{
options.my.profiles.gtk = with lib; {
enable = mkEnableOption "gtk profile";
};
config = lib.mkIf cfg.enable {
# Allow setting GTK configuration using home-manager
programs.dconf.enable = true;
# GTK theme configuration
my.home.gtk.enable = true;
};
}

View file

@ -1,23 +0,0 @@
{ config, lib, ... }:
let
cfg = config.my.profiles.laptop;
in
{
options.my.profiles.laptop = with lib; {
enable = mkEnableOption "laptop profile";
};
config = lib.mkIf cfg.enable {
# Enable touchpad support
services.libinput.enable = true;
# Enable TLP power management
my.services.tlp.enable = true;
# Enable upower power management
my.hardware.upower.enable = true;
# Enable battery notifications
my.home.power-alert.enable = true;
};
}

View file

@ -1,31 +0,0 @@
{ config, lib, ... }:
let
cfg = config.my.profiles.wm;
in
{
options.my.profiles.wm = with lib; {
windowManager = mkOption {
type = with types; nullOr (enum [ "i3" ]);
default = null;
example = "i3";
description = "Which window manager to use";
};
};
config = lib.mkMerge [
(lib.mkIf (cfg.windowManager == "i3") {
# Enable i3
services.xserver.windowManager.i3.enable = true;
# i3 settings
my.home.wm.windowManager = "i3";
# Screenshot tool
my.home.flameshot.enable = true;
# Auto disk mounter
my.home.udiskie.enable = true;
# udiskie fails if it can't find this dbus service
services.udisks2.enable = true;
# Ensure i3lock can actually unlock the session
security.pam.services.i3lock.enable = true;
})
];
}

View file

@ -1,23 +0,0 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.profiles.x;
in
{
options.my.profiles.x = with lib; {
enable = mkEnableOption "X profile";
};
config = lib.mkIf cfg.enable {
# Enable the X11 windowing system.
services.xserver.enable = true;
# Nice wallpaper
services.xserver.displayManager.lightdm.background =
let
wallpapers = "${pkgs.kdePackages.plasma-workspace-wallpapers}/share/wallpapers";
in
"${wallpapers}/summer_1am/contents/images/2560x1600.jpg";
# X configuration
my.home.x.enable = true;
};
}

View file

@ -38,7 +38,6 @@
./servarr ./servarr
./ssh-server ./ssh-server
./tandoor-recipes ./tandoor-recipes
./thelounge
./tlp ./tlp
./transmission ./transmission
./vikunja ./vikunja

View file

@ -39,7 +39,7 @@ in
my.services.backup = { my.services.backup = {
paths = [ paths = [
(lib.removePrefix "file://" config.services.homebox.settings.HBOX_STORAGE_CONN_STRING) config.services.homebox.settings.HBOX_STORAGE_DATA
]; ];
}; };

View file

@ -1,143 +0,0 @@
# Matrix bridges for some services I use
{ config, lib, ... }:
let
cfg = config.my.services.matrix.bridges;
synapseCfg = config.services.matrix-synapse;
domain = config.networking.domain;
serverName = synapseCfg.settings.server_name;
mkBridgeOption = n: lib.mkEnableOption "${n} bridge" // { default = cfg.enable; };
mkPortOption = n: default: lib.mkOption {
type = lib.types.port;
inherit default;
example = 8080;
description = "${n} bridge port";
};
mkEnvironmentFileOption = n: lib.mkOption {
type = lib.types.str;
example = "/run/secret/matrix/${lib.toLower n}-bridge-secrets.env";
description = ''
Path to a file which should contain the secret values for ${n} bridge.
Using through the following format:
```
MATRIX_APPSERVICE_AS_TOKEN=<the_as_value>
MATRIX_APPSERVICE_HS_TOKEN=<the_hs_value>
```
Each bridge should use a different set of secrets, as they each register
their own independent double-puppetting appservice.
'';
};
in
{
options.my.services.matrix.bridges = with lib; {
enable = mkEnableOption "bridges configuration";
admin = mkOption {
type = types.str;
default = "ambroisie";
example = "admin";
description = "Local username for the admin";
};
facebook = {
enable = mkBridgeOption "Facebook";
port = mkPortOption "Facebook" 29321;
environmentFile = mkEnvironmentFileOption "Facebook";
};
};
config = lib.mkMerge [
(lib.mkIf cfg.facebook.enable {
services.mautrix-meta.instances.facebook = {
enable = true;
# Automatically register the bridge with synapse
registerToSynapse = true;
# Provide `AS_TOKEN`, `HS_TOKEN`
inherit (cfg.facebook) environmentFile;
settings = {
homeserver = {
domain = serverName;
address = "http://localhost:${toString config.my.services.matrix.port}";
};
appservice = {
hostname = "localhost";
inherit (cfg.facebook) port;
address = "http://localhost:${toString cfg.facebook.port}";
public_address = "https://facebook-bridge.${domain}";
as_token = "$MATRIX_APPSERVICE_AS_TOKEN";
hs_token = "$MATRIX_APPSERVICE_HS_TOKEN";
bot = {
username = "fbbot";
};
};
backfill = {
enabled = true;
};
bridge = {
delivery_receipts = true;
permissions = {
"*" = "relay";
${serverName} = "user";
"@${cfg.admin}:${serverName}" = "admin";
};
};
database = {
type = "postgres";
uri = "postgres:///mautrix-meta-facebook?host=/var/run/postgresql/";
};
double_puppet = {
secrets = {
${serverName} = "as_token:$MATRIX_APPSERVICE_AS_TOKEN";
};
};
network = {
# Don't be picky on Facebook/Messenger
allow_messenger_com_on_fb = true;
displayname_template = ''{{or .DisplayName .Username "Unknown user"}} (FB)'';
};
provisioning = {
shared_secret = "disable";
};
};
};
services.postgresql = {
enable = true;
ensureDatabases = [ "mautrix-meta-facebook" ];
ensureUsers = [{
name = "mautrix-meta-facebook";
ensureDBOwnership = true;
}];
};
systemd.services.mautrix-meta-facebook = {
wants = [ "postgres.service" ];
after = [ "postgres.service" ];
};
my.services.nginx.virtualHosts = {
# Proxy to the bridge
"facebook-bridge" = {
inherit (cfg.facebook) port;
};
};
})
];
}

View file

@ -1,49 +1,24 @@
# Matrix homeserver setup. # Matrix homeserver setup, using different endpoints for federation and client
# traffic. The main trick for this is defining two nginx servers endpoints for
# matrix.domain.com, each listening on different ports.
#
# Configuration shamelessly stolen from [1]
#
# [1]: https://github.com/alarsyo/nixos-config/blob/main/services/matrix.nix
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
cfg = config.my.services.matrix; cfg = config.my.services.matrix;
adminPkg = pkgs.synapse-admin-etkecc; federationPort = { public = 8448; private = 11338; };
clientPort = { public = 443; private = 11339; };
domain = config.networking.domain; domain = config.networking.domain;
matrixDomain = "matrix.${domain}"; matrixDomain = "matrix.${domain}";
serverConfig = {
"m.server" = "${matrixDomain}:443";
};
clientConfig = {
"m.homeserver" = {
"base_url" = "https://${matrixDomain}";
"server_name" = domain;
};
"m.identity_server" = {
"base_url" = "https://vector.im";
};
};
# ACAO required to allow element-web on any URL to request this json file
mkWellKnown = data: ''
default_type application/json;
add_header Access-Control-Allow-Origin *;
return 200 '${builtins.toJSON data}';
'';
in in
{ {
imports = [
./bridges.nix
];
options.my.services.matrix = with lib; { options.my.services.matrix = with lib; {
enable = mkEnableOption "Matrix Synapse"; enable = mkEnableOption "Matrix Synapse";
port = mkOption {
type = types.port;
default = 8448;
example = 8008;
description = "Internal port for listeners";
};
secretFile = mkOption { secretFile = mkOption {
type = with types; nullOr str; type = with types; nullOr str;
default = null; default = null;
@ -83,22 +58,22 @@ in
enable_registration = false; enable_registration = false;
listeners = [ listeners = [
# Federation
{ {
inherit (cfg) port;
bind_addresses = [ "::1" ]; bind_addresses = [ "::1" ];
type = "http"; port = federationPort.private;
tls = false; tls = false; # Terminated by nginx.
x_forwarded = true; x_forwarded = true;
resources = [ resources = [{ names = [ "federation" ]; compress = false; }];
{ }
names = [ "client" ];
compress = true; # Client
} {
{ bind_addresses = [ "::1" ];
names = [ "federation" ]; port = clientPort.private;
compress = false; tls = false; # Terminated by nginx.
} x_forwarded = true;
]; resources = [{ names = [ "client" ]; compress = false; }];
} }
]; ];
@ -121,12 +96,19 @@ in
chat = { chat = {
root = pkgs.element-web.override { root = pkgs.element-web.override {
conf = { conf = {
default_server_config = clientConfig; default_server_config = {
show_labs_settings = true; "m.homeserver" = {
default_country_code = "FR"; # cocorico "base_url" = "https://${matrixDomain}";
room_directory = { "server_name" = domain;
};
"m.identity_server" = {
"base_url" = "https://vector.im";
};
};
showLabsSettings = true;
defaultCountryCode = "FR"; # cocorico
roomDirectory = {
"servers" = [ "servers" = [
domain
"matrix.org" "matrix.org"
"mozilla.org" "mozilla.org"
]; ];
@ -134,54 +116,99 @@ in
}; };
}; };
}; };
matrix = { # Dummy VHosts for port collision detection
# Somewhat unused, but necessary for port collision detection matrix-federation = {
inherit (cfg) port; port = federationPort.private;
};
extraConfig = { matrix-client = {
locations = { port = clientPort.private;
# Or do a redirect instead of the 404, or whatever is appropriate
# for you. But do not put a Matrix Web client here! See the
# Element web section above.
"/".return = "404";
"/_matrix".proxyPass = "http://[::1]:${toString cfg.port}";
"/_synapse".proxyPass = "http://[::1]:${toString cfg.port}";
"= /admin".return = "307 /admin/";
"/admin/" = {
alias = "${adminPkg}/";
priority = 500;
tryFiles = "$uri $uri/ /index.html";
};
"~ ^/admin/.*\\.(?:css|js|jpg|jpeg|gif|png|svg|ico|woff|woff2|ttf|eot|webp)$" = {
priority = 400;
root = adminPkg;
extraConfig = ''
rewrite ^/admin/(.*)$ /$1 break;
expires 30d;
more_set_headers "Cache-Control: public";
'';
};
};
};
}; };
}; };
# Setup well-known locations # Those are too complicated to use my wrapper...
services.nginx.virtualHosts = { services.nginx.virtualHosts = {
${matrixDomain} = {
onlySSL = true;
useACMEHost = domain;
locations =
let
proxyToClientPort = {
proxyPass = "http://[::1]:${toString clientPort.private}";
};
in
{
# Or do a redirect instead of the 404, or whatever is appropriate
# for you. But do not put a Matrix Web client here! See the
# Element web section below.
"/".return = "404";
"/_matrix" = proxyToClientPort;
"/_synapse/client" = proxyToClientPort;
};
listen = [
{ addr = "0.0.0.0"; port = clientPort.public; ssl = true; }
{ addr = "[::]"; port = clientPort.public; ssl = true; }
];
};
# same as above, but listening on the federation port
"${matrixDomain}_federation" = {
onlySSL = true;
serverName = matrixDomain;
useACMEHost = domain;
locations."/".return = "404";
locations."/_matrix" = {
proxyPass = "http://[::1]:${toString federationPort.private}";
};
listen = [
{ addr = "0.0.0.0"; port = federationPort.public; ssl = true; }
{ addr = "[::]"; port = federationPort.public; ssl = true; }
];
};
"${domain}" = { "${domain}" = {
forceSSL = true; forceSSL = true;
useACMEHost = domain; useACMEHost = domain;
locations."= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig; locations."= /.well-known/matrix/server".extraConfig =
locations."= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig; let
server = { "m.server" = "${matrixDomain}:${toString federationPort.public}"; };
in
''
add_header Content-Type application/json;
return 200 '${builtins.toJSON server}';
'';
locations."= /.well-known/matrix/client".extraConfig =
let
client = {
"m.homeserver" = { "base_url" = "https://${matrixDomain}"; };
"m.identity_server" = { "base_url" = "https://vector.im"; };
};
# ACAO required to allow element-web on any URL to request this json file
in
''
add_header Content-Type application/json;
add_header Access-Control-Allow-Origin *;
return 200 '${builtins.toJSON client}';
'';
}; };
}; };
# For administration tools. # For administration tools.
environment.systemPackages = [ pkgs.matrix-synapse ]; environment.systemPackages = [ pkgs.matrix-synapse ];
networking.firewall.allowedTCPPorts = [
clientPort.public
federationPort.public
];
my.services.backup = { my.services.backup = {
paths = [ paths = [
config.services.matrix-synapse.dataDir config.services.matrix-synapse.dataDir

View file

@ -32,7 +32,6 @@ in
BASE_URL = "https://mealie.${config.networking.domain}"; BASE_URL = "https://mealie.${config.networking.domain}";
TZ = config.time.timeZone; TZ = config.time.timeZone;
ALLOw_SIGNUP = "false"; ALLOw_SIGNUP = "false";
TOKEN_TIME = 24 * 180; # 180 days
}; };
# Automatic PostgreSQL provisioning # Automatic PostgreSQL provisioning
@ -54,12 +53,6 @@ in
}; };
}; };
my.services.backup = {
paths = [
"/var/lib/mealie"
];
};
services.fail2ban.jails = { services.fail2ban.jails = {
mealie = '' mealie = ''
enabled = true enabled = true

View file

@ -16,12 +16,6 @@ in
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.nextcloud = {
extraApps = {
inherit (config.services.nextcloud.package.packages.apps) richdocuments;
};
};
services.collabora-online = { services.collabora-online = {
enable = true; enable = true;
inherit (cfg) port; inherit (cfg) port;

View file

@ -35,7 +35,7 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.nextcloud = { services.nextcloud = {
enable = true; enable = true;
package = pkgs.nextcloud32; package = pkgs.nextcloud31;
hostName = "nextcloud.${config.networking.domain}"; hostName = "nextcloud.${config.networking.domain}";
home = "/var/lib/nextcloud"; home = "/var/lib/nextcloud";
maxUploadSize = cfg.maxSize; maxUploadSize = cfg.maxSize;
@ -62,16 +62,6 @@ in
# Allow using the push service without hard-coding my IP in the configuration # Allow using the push service without hard-coding my IP in the configuration
bendDomainToLocalhost = true; bendDomainToLocalhost = true;
}; };
extraApps = {
inherit (config.services.nextcloud.package.packages.apps)
calendar
contacts
deck
tasks
;
# notify_push is automatically installed by the module
};
}; };
# The service above configures the domain, no need for my wrapper # The service above configures the domain, no need for my wrapper

View file

@ -444,7 +444,7 @@ in
}; };
}; };
systemd.services."acme-order-renew-${domain}" = { systemd.services."acme-${domain}" = {
serviceConfig = { serviceConfig = {
Environment = [ Environment = [
# Since I do a "weird" setup with a wildcard CNAME # Since I do a "weird" setup with a wildcard CNAME

View file

@ -26,16 +26,18 @@ in
services.tandoor-recipes = { services.tandoor-recipes = {
enable = true; enable = true;
database = {
createLocally = true;
};
port = cfg.port; port = cfg.port;
extraConfig = extraConfig =
let let
tandoorRecipesDomain = "recipes.${config.networking.domain}"; tandoorRecipesDomain = "recipes.${config.networking.domain}";
in in
{ {
# Use PostgreSQL
DB_ENGINE = "django.db.backends.postgresql";
POSTGRES_HOST = "/run/postgresql";
POSTGRES_USER = "tandoor_recipes";
POSTGRES_DB = "tandoor_recipes";
# Security settings # Security settings
ALLOWED_HOSTS = tandoorRecipesDomain; ALLOWED_HOSTS = tandoorRecipesDomain;
CSRF_TRUSTED_ORIGINS = "https://${tandoorRecipesDomain}"; CSRF_TRUSTED_ORIGINS = "https://${tandoorRecipesDomain}";
@ -47,12 +49,27 @@ in
systemd.services = { systemd.services = {
tandoor-recipes = { tandoor-recipes = {
after = [ "postgresql.target" ];
requires = [ "postgresql.target" ];
serviceConfig = { serviceConfig = {
EnvironmentFile = cfg.secretKeyFile; EnvironmentFile = cfg.secretKeyFile;
}; };
}; };
}; };
# Set-up database
services.postgresql = {
enable = true;
ensureDatabases = [ "tandoor_recipes" ];
ensureUsers = [
{
name = "tandoor_recipes";
ensureDBOwnership = true;
}
];
};
my.services.nginx.virtualHosts = { my.services.nginx.virtualHosts = {
recipes = { recipes = {
inherit (cfg) port; inherit (cfg) port;

View file

@ -1,59 +0,0 @@
# Web IRC client
{ config, lib, ... }:
let
cfg = config.my.services.thelounge;
in
{
options.my.services.thelounge = with lib; {
enable = mkEnableOption "The Lounge, a self-hosted web IRC client";
port = mkOption {
type = types.port;
default = 9050;
example = 4242;
description = "The port on which The Lounge will listen for incoming HTTP traffic.";
};
};
config = lib.mkIf cfg.enable {
services.thelounge = {
enable = true;
inherit (cfg) port;
extraConfig = {
reverseProxy = true;
};
};
my.services.nginx.virtualHosts = {
irc = {
inherit (cfg) port;
# Proxy websockets for RPC
websocketsLocations = [ "/" ];
extraConfig = {
locations."/".extraConfig = ''
proxy_read_timeout 1d;
'';
};
};
};
services.fail2ban.jails = {
thelounge = ''
enabled = true
filter = thelounge
port = http,https
'';
};
environment.etc = {
"fail2ban/filter.d/thelounge.conf".text = ''
[Definition]
failregex = Authentication failed for user .* from <HOST>$
Authentication for non existing user attempted from <HOST>$
journalmatch = _SYSTEMD_UNIT=thelounge.service
'';
};
};
}

View file

@ -71,14 +71,10 @@ in
}; };
}; };
# Transmission wants to eat *all* my RAM if left to its own devices
systemd.services.transmission = { systemd.services.transmission = {
serviceConfig = { serviceConfig = {
# Transmission wants to eat *all* my RAM if left to its own devices
MemoryMax = "33%"; MemoryMax = "33%";
# Avoid errors due to high number of open files.
LimitNOFILE = 1048576;
# Longer stop timeout to finish all torrents
TimeoutStopSec = "5m";
}; };
}; };

View file

@ -12,9 +12,9 @@ usage() {
find_program() { find_program() {
local CANDIDATE local CANDIDATE
CANDIDATE="$(nix-locate --minimal --at-root --whole-name "/bin/$1")" CANDIDATE="$(nix-locate --top-level --minimal --at-root --whole-name "/bin/$1")"
if [ "$(printf '%s\n' "$CANDIDATE" | wc -l)" -gt 1 ]; then if [ "$(printf '%s\n' "$CANDIDATE" | wc -l)" -gt 1 ]; then
CANDIDATE="$(printf '%s' "$CANDIDATE" | "${COMMA_PICKER:-fzf-tmux}")" CANDIDATE="$(printf '%s' "$CANDIDATE" | fzf-tmux)"
fi fi
printf '%s' "$CANDIDATE" printf '%s' "$CANDIDATE"
} }

View file

@ -10,6 +10,7 @@ rustPlatform.buildRustPackage rec {
hash = "sha256-dunQgtap+XCK5LoSyOqIY/6p6HizBeiyPWNuCffwjDU="; hash = "sha256-dunQgtap+XCK5LoSyOqIY/6p6HizBeiyPWNuCffwjDU=";
}; };
useFetchCargoVendor = true;
cargoHash = "sha256-R3/N/43+bGx6acE/rhBcrk6kS5zQu8NJ1sVvKJJkK9w="; cargoHash = "sha256-R3/N/43+bGx6acE/rhBcrk6kS5zQu8NJ1sVvKJJkK9w=";
meta = with lib; { meta = with lib; {