Reformat nix code, and add a few CLI utilities

This commit is contained in:
Konstantin Nazarov 2023-09-30 23:07:32 +01:00
parent f97fbed4fe
commit 8fd7e4c619
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22
4 changed files with 245 additions and 222 deletions

View file

@ -4,13 +4,9 @@
{ config, lib, nixpkgs, pkgs, home-manager, ... }:
let
my_python = (pkgs.python3.withPackages (ps: with ps; [
git_plan]));
in
{
imports =
[
let my_python = (pkgs.python3.withPackages (ps: with ps; [ git_plan ]));
in {
imports = [
#./gnupg.nix
];
nix.settings.experimental-features = [ "nix-command" "flakes" ];
@ -76,7 +72,6 @@ in
package = lib.mkForce pkgs.gnome3.gvfs;
};
# Configure keymap in X11
services.xserver = {
layout = "us";
@ -87,11 +82,7 @@ in
users.users.knazarov = {
isNormalUser = true;
description = "Konstantin Nazarov";
extraGroups = [
"networkmanager"
"wheel"
config.users.groups.keys.name
];
extraGroups = [ "networkmanager" "wheel" config.users.groups.keys.name ];
packages = with pkgs; [ ];
openssh.authorizedKeys.keys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDGxebDydOcs7URJjXFHMU++ruaZOJpXbK4ixH19pWTsX7WtxxriZxD4+RQ3oyllGG/8sEFzEe0NoTHUPU6YrBpfwT/ekGDmCJHtvZ+rZs+cRQd6tObfAUip1B1Mcvhuaj0prnrbfohOuHpvQ/L8TogIKuHgczDmud4KGUu0mxCsUHbD5tlKpsgN+dJXkvjxsO7JhhF9JpFTrYAU0gTuBPTt3ynpnZKrE1NgnE0iy+CEr/v41dLqxw3fUjT3nOFUQ1l/VKTw5mLt5Iw7XmBLuFGLRAVrwzXxeBCfYqKGYgY4QV8HCcVpcqC8zWmRskiRetzQ/5HwRagm4yZr0I+LZ305nGB0cSJzLWXXOUF6SDg2cqAXFpF/o2LoFCmaV5h3jmCGOUrowF7oV4mYwBMWfabrbZx21z/R56GkAOOEKc2h+Qh5wIj4yayX081SkqJK3J9+3vGG4VvXnwGnPnWQFqrzeedyV74maffGBGFYm0UOcD+oG6EwM+7MEUBpJm9m4c= knazarov"
@ -131,6 +122,7 @@ in
pciutils
slack
q-sh
notes-sh
transmission-gtk
mpv
imv
@ -161,14 +153,16 @@ in
xournalpp
dnsutils
graphviz
fzf
nixfmt
#network-manager-applet
(clang-tools.override { llvmPackages = llvmPackages_16; }) # mainly for clang-format
(clang-tools.override {
llvmPackages = llvmPackages_16;
}) # mainly for clang-format
(emacsWithPackagesFromUsePackage {
config = ./emacs.el;
defaultInitFile = true;
package = emacs29-pgtk.overrideAttrs (old: {
withTreeSitter = true;
});
package = emacs29-pgtk.overrideAttrs (old: { withTreeSitter = true; });
alwaysEnsure = true;
extraEmacsPackages = epkgs: [
pkgs.mu
@ -179,11 +173,9 @@ in
my_python
];
services.mullvad-vpn = {
enable = true;
};
systemd.services."mullvad-daemon".postStart = let
mullvad = config.services.mullvad-vpn.package;
services.mullvad-vpn = { enable = true; };
systemd.services."mullvad-daemon".postStart =
let mullvad = config.services.mullvad-vpn.package;
in ''
while ! ${mullvad}/bin/mullvad status >/dev/null; do sleep 1; done
${mullvad}/bin/mullvad account login `cat /var/run/secrets/mullvad_account`
@ -191,7 +183,6 @@ in
${mullvad}/bin/mullvad tunnel ipv6 set on
'';
services.fwupd.enable = true;
services.gnome.gnome-keyring.enable = true;
@ -201,7 +192,8 @@ in
environment.sessionVariables.NIXOS_OZONE_WL = "1";
# Set default browser to qutebrowser in electron apps
environment.sessionVariables.DEFAULT_BROWSER = "${pkgs.qutebrowser}/bin/qutebrowser";
environment.sessionVariables.DEFAULT_BROWSER =
"${pkgs.qutebrowser}/bin/qutebrowser";
# Set default browser to qutebrowser everywhere else
xdg.mime.defaultApplications = {
@ -224,9 +216,6 @@ in
};
};
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
@ -352,12 +341,14 @@ in
networking.firewall.allowedTCPPorts = [
# Syncthing
8384 22000
8384
22000
];
networking.firewall.allowedUDPPorts = [
# Syncthing
22000 21027
22000
21027
];
# This value determines the NixOS release from which the default
@ -386,9 +377,8 @@ in
font-awesome # for waybar indicators
];
home-manager.users.knazarov = {
/* The home.stateVersion option does not have a default and must be set */
# The home.stateVersion option does not have a default and must be set
home.stateVersion = "23.05";
programs.bash = {
@ -404,31 +394,29 @@ in
gtk = {
enable = true;
gtk3.extraConfig = {
gtk-enable-animations = "0";
};
gtk4.extraConfig = {
gtk-enable-animations = "0";
};
gtk3.extraConfig = { gtk-enable-animations = "0"; };
gtk4.extraConfig = { gtk-enable-animations = "0"; };
};
programs.direnv = {
enable = true;
nix-direnv = {
enable = true;
};
nix-direnv = { enable = true; };
};
programs.gpg = {
enable = true;
package = pkgs.gnupg;
publicKeys = [
{source = ./gpg_public_key.asc; trust="ultimate"; }
{source = ./pgp_keys/FB4809DC51A4F483.asc; trust= "ultimate"; }
{
source = ./gpg_public_key.asc;
trust = "ultimate";
}
{
source = ./pgp_keys/FB4809DC51A4F483.asc;
trust = "ultimate";
}
];
settings = {
default-key = "0x0560020C9C577C1B";
};
settings = { default-key = "0x0560020C9C577C1B"; };
mutableKeys = false;
mutableTrust = false;
};
@ -448,7 +436,8 @@ in
accounts.email = {
maildirBasePath = "${config.users.users.knazarov.home}/Maildir";
accounts = {
personal = let account = "mail@knazarov.com"; in {
personal = let account = "mail@knazarov.com";
in {
primary = true;
flavor = "fastmail.com";
address = account;
@ -471,14 +460,10 @@ in
};
};
programs.mu = {
enable = true;
};
programs.mu = { enable = true; };
programs.msmtp.enable = true;
programs.mbsync = {
enable = true;
};
programs.mbsync = { enable = true; };
#services.easyeffects = {
# enable = true;
@ -487,14 +472,20 @@ in
services.swayidle = {
enable = true;
timeouts = [
{ timeout = 300; command = "${pkgs.swaylock}/bin/swaylock -f -c 000000";}
{ timeout = 600;
command = "${pkgs.sway}/bin/swaymsg \"output * dpms off\"";
resumeCommand = "${pkgs.sway}/bin/swaymsg \"output * dpms on\"";}
];
events = [
{ event = "before-sleep"; command = "${pkgs.swaylock}/bin/swaylock -f -c 000000"; }
{
timeout = 300;
command = "${pkgs.swaylock}/bin/swaylock -f -c 000000";
}
{
timeout = 600;
command = ''${pkgs.sway}/bin/swaymsg "output * dpms off"'';
resumeCommand = ''${pkgs.sway}/bin/swaymsg "output * dpms on"'';
}
];
events = [{
event = "before-sleep";
command = "${pkgs.swaylock}/bin/swaylock -f -c 000000";
}];
};
wayland.windowManager.sway = {
@ -503,19 +494,23 @@ in
config = rec {
modifier = "Mod4";
terminal = "foot";
bars = [{
"command" = "waybar";
}];
bars = [{ "command" = "waybar"; }];
keybindings = pkgs.lib.mkOptionDefault {
"XF86AudioRaiseVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+";
"XF86AudioLowerVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-";
"XF86AudioRaiseVolume" =
"exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+";
"XF86AudioLowerVolume" =
"exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-";
"XF86AudioMute" = "exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
"XF86AudioMicMute" = "exec pactl set-source-mute @DEFAULT_SOURCE@ toggle";
"XF86AudioMicMute" =
"exec pactl set-source-mute @DEFAULT_SOURCE@ toggle";
"XF86MonBrightnessUp" = "exec brightnessctl s +5%";
"XF86MonBrightnessDown" = "exec brightnessctl s 5%-";
"Mod4+Return" = "exec emacs --eval '(progn (setq confirm-kill-processes nil) (vterm))'";
"Mod4+space" = "exec ${pkgs.foot}/bin/foot -T mylauncher -a mylauncher ${pkgs.q-sh}/bin/q";
"Mod4+p" = "exec '${pkgs.grim}/bin/grim -g \"$$(${pkgs.slurp}/bin/slurp)\" - | ${pkgs.wl-clipboard}/bin/wl-copy -t image/png'";
"Mod4+Return" =
"exec emacs --eval '(progn (setq confirm-kill-processes nil) (vterm))'";
"Mod4+space" =
"exec ${pkgs.foot}/bin/foot -T mylauncher -a mylauncher ${pkgs.q-sh}/bin/q";
"Mod4+p" =
"exec '${pkgs.grim}/bin/grim -g \"$$(${pkgs.slurp}/bin/slurp)\" - | ${pkgs.wl-clipboard}/bin/wl-copy -t image/png'";
};
output = {
"*" = { bg = "${./wallpaper.jpg} fill"; };
@ -531,11 +526,13 @@ in
inner = 10;
outer = 5;
};
colors.unfocused = {border = "#dddddd";
colors.unfocused = {
border = "#dddddd";
background = "#dddddd";
text = "#888888";
indicator = "#888888";
childBorder = "#888888";};
childBorder = "#888888";
};
};
extraConfig = ''
for_window [title="mylauncher"] floating enable
@ -547,9 +544,7 @@ in
programs.foot = {
enable = true;
settings = {
main = {
font="monospace:size=10";
};
main = { font = "monospace:size=10"; };
colors = {
background = "feffff";
@ -601,9 +596,7 @@ in
config.set('content.register_protocol_handler', False, 'https://calendar.google.com?cid=%25s')
'';
keyBindings = {
insert = {
"<Shift+Ins>" = "insert-text -- {clipboard}";
};
insert = { "<Shift+Ins>" = "insert-text -- {clipboard}"; };
};
};
programs.waybar = {
@ -614,8 +607,7 @@ in
height = 24;
modules-left = [ "sway/workspaces" "sway/mode" ];
modules-center = [ "sway/window" ];
modules-right =
[ "idle_inhibitor" "battery" "clock" "tray" ];
modules-right = [ "idle_inhibitor" "battery" "clock" "tray" ];
clock.format = "{:%Y-%m-%d %H:%M}";
battery = {
states = {
@ -638,9 +630,7 @@ in
};
}];
};
services.syncthing = {
enable = true;
};
services.syncthing = { enable = true; };
home.pointerCursor = {
name = "Adwaita";
package = pkgs.gnome.adwaita-icon-theme;
@ -656,20 +646,16 @@ in
podman = {
enable = true;
dockerCompat = true;
defaultNetwork.settings = {
dns_enabled = true;
defaultNetwork.settings = { dns_enabled = true; };
};
};
};
services.udev.packages = [
pkgs.android-udev-rules
];
services.udev.packages = [ pkgs.android-udev-rules ];
#udevadm info --query=all --name=/dev/sda1 | grep ID_SERIAL
services.udev.extraRules =
''ACTION=="add", SUBSYSTEMS=="usb", SUBSYSTEM=="block", '' +
''ENV{ID_FS_USAGE}=="filesystem", ENV{ID_SERIAL_SHORT}=="Hidizs_AP80PRO", '' +
''RUN{program}+="${pkgs.systemd}/bin/systemd-mount --owner knazarov '' +
''--no-block --automount=yes --collect $devnode /media"'';
''ACTION=="add", SUBSYSTEMS=="usb", SUBSYSTEM=="block", '' + ''
ENV{ID_FS_USAGE}=="filesystem", ENV{ID_SERIAL_SHORT}=="Hidizs_AP80PRO", ''
+ ''RUN{program}+="${pkgs.systemd}/bin/systemd-mount --owner knazarov ''
+ ''--no-block --automount=yes --collect $devnode /media"'';
systemd.timers."git_plan" = {
wantedBy = [ "timers.target" ];

View file

@ -290,6 +290,9 @@
(evil-define-key 'normal 'global (kbd "<leader>b") 'switch-to-buffer)
(evil-define-key 'normal 'global (kbd "<leader>r") 'consult-ripgrep)
;; Make :q close the current buffer, and not the whole emacs process
(global-set-key [remap evil-quit] 'kill-buffer-and-window)
;; -------- Tools and environment --------
;; By default, Emacs doesn't add system path to its search places

View file

@ -90,11 +90,11 @@
]
},
"locked": {
"lastModified": 1695674553,
"narHash": "sha256-gl/4yEfN0nsAhY/gBRO/GmxbbJZMQHXERm7Jrr2lJug=",
"lastModified": 1695939862,
"narHash": "sha256-YKDlS3HCXiMflP5i/uEQnZf2henO10beetINHj80hmU=",
"owner": "~knazarov",
"repo": "knazarov.com",
"rev": "b851bb106e03996a1c00212986217db464b90424",
"rev": "ea70e4a202b4fdc0e5e20c5fce9a631093d3cf35",
"type": "sourcehut"
},
"original": {
@ -134,6 +134,26 @@
"type": "github"
}
},
"notes-sh": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1696081283,
"narHash": "sha256-ldiJ3gWOvW/aq3zwetnSg1pjU7PfKYVsQWxIZGM/NNA=",
"owner": "~knazarov",
"repo": "notes.sh",
"rev": "38e2883be54cd6634d83888f8f8545ddb44b9556",
"type": "sourcehut"
},
"original": {
"owner": "~knazarov",
"repo": "notes.sh",
"type": "sourcehut"
}
},
"q-sh": {
"inputs": {
"nixpkgs": [
@ -162,6 +182,7 @@
"knazarovcom": "knazarovcom",
"nixpkgs": "nixpkgs",
"nixpkgs-stable": "nixpkgs-stable",
"notes-sh": "notes-sh",
"q-sh": "q-sh",
"sops-nix": "sops-nix",
"vmatveevacom": "vmatveevacom"

View file

@ -3,36 +3,40 @@
{
inputs = {
nixpkgs.url = github:NixOS/nixpkgs;
nixpkgs-stable.url = github:NixOS/nixpkgs/nixos-23.05;
home-manager.url = github:nix-community/home-manager/release-23.05;
nixpkgs.url = "github:NixOS/nixpkgs";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-23.05";
home-manager.url = "github:nix-community/home-manager/release-23.05";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
emacs-overlay.url = github:nix-community/emacs-overlay;
emacs-overlay.url = "github:nix-community/emacs-overlay";
emacs-overlay.inputs.nixpkgs.follows = "nixpkgs";
emacs-overlay.inputs.nixpkgs-stable.follows = "nixpkgs-stable";
sops-nix.url = github:Mic92/sops-nix;
sops-nix.url = "github:Mic92/sops-nix";
sops-nix.inputs.nixpkgs.follows = "nixpkgs";
sops-nix.inputs.nixpkgs-stable.follows = "nixpkgs-stable";
q-sh.url = sourcehut:~knazarov/q.sh;
q-sh.url = "sourcehut:~knazarov/q.sh";
q-sh.inputs.nixpkgs.follows = "nixpkgs";
knazarovcom.url = sourcehut:~knazarov/knazarov.com;
notes-sh.url = "sourcehut:~knazarov/notes.sh";
notes-sh.inputs.nixpkgs.follows = "nixpkgs";
knazarovcom.url = "sourcehut:~knazarov/knazarov.com";
knazarovcom.inputs.nixpkgs.follows = "nixpkgs";
vmatveevacom.url = github:valeriya-matveeva/vmatveeva.com;
vmatveevacom.url = "github:valeriya-matveeva/vmatveeva.com";
vmatveevacom.inputs.nixpkgs.follows = "nixpkgs";
git-plan.url = sourcehut:~knazarov/git-plan;
git-plan.url = "sourcehut:~knazarov/git-plan";
git-plan.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, nixpkgs-stable, home-manager, emacs-overlay, sops-nix, q-sh, knazarovcom, vmatveevacom, git-plan, ... }@attrs:
outputs = { self, nixpkgs, nixpkgs-stable, home-manager, emacs-overlay
, sops-nix, q-sh, notes-sh, knazarovcom, vmatveevacom, git-plan, ...
}@attrs:
let
system = "x86_64-linux";
specialArgs = {
inherit attrs;
};
specialArgs = { inherit attrs; };
buildConfig = modules: system: { inherit modules system specialArgs; };
buildSystem = modules: system: nixpkgs.lib.nixosSystem (buildConfig modules system);
buildSystemStable = modules: system: nixpkgs-stable.lib.nixosSystem (buildConfig modules system);
buildSystem = modules: system:
nixpkgs.lib.nixosSystem (buildConfig modules system);
buildSystemStable = modules: system:
nixpkgs-stable.lib.nixosSystem (buildConfig modules system);
hostAttrs = dir: {
settings = import "${dir}/host-metadata.nix";
@ -40,33 +44,42 @@
hw-config = import "${dir}/hardware-configuration.nix";
};
node = dir: with hostAttrs dir; buildSystemStable [
({ config, pkgs, ... }: { nixpkgs.overlays = [ emacs-overlay.overlay q-sh.overlays.default
node = dir:
with hostAttrs dir;
buildSystemStable [
({ config, pkgs, ... }: {
nixpkgs.overlays = [
emacs-overlay.overlay
q-sh.overlays.default
notes-sh.overlays.default
git-plan.overlays.default
]; })
];
})
sops-nix.nixosModules.sops
home-manager.nixosModule
config
hw-config
./configuration.nix
]
settings.system;
] settings.system;
server = dir: with hostAttrs dir; buildSystem [
({ config, pkgs, ... }: { nixpkgs.overlays = [
server = dir:
with hostAttrs dir;
buildSystem [
({ config, pkgs, ... }: {
nixpkgs.overlays = [
emacs-overlay.overlay
q-sh.overlays.default
knazarovcom.overlays.default
vmatveevacom.overlays.default]; })
vmatveevacom.overlays.default
];
})
sops-nix.nixosModules.sops
home-manager.nixosModule
config
hw-config
#(dir + "/configuration.nix")
]
settings.system;
in
{
] settings.system;
in {
nixosConfigurations = {
mira = node ./nodes/mira;
framework = node ./nodes/framework;