From 8b80ba24c2eaba86b3b0bf4336442837e936a5d1 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Sat, 14 May 2022 00:01:08 +0200 Subject: [PATCH] Various changes - `hs` host - cam subdomain behind reverse proxy - dynamic dns updater script - `pc` host - ext4 instead of btrfs - ca-derivations experimental feature - nix from unstable channel (2.8) - cura from stable (unstable went broken) - Emacs - company-nixos-options - helm-nixos-options - nix-modeline - disable format hook on save for nix mode - nix from master (only in overlay, not used) - bat (alias for cat) - batman (alias for batman) - disabled weird extra options for nix I couldn't even remember of - Fira Code for sway/waybar - New plain style for waybar --- .gitignore | 2 + flake.lock | 12 +- hosts/hs/configuration.nix | 47 ++++- hosts/pc/configuration.nix | 17 +- pkgs/default.nix | 4 +- pkgs/emacs/default.nix | 4 + pkgs/nix-from-master/default.nix | 9 + profiles/cachix/ca-derivations.nix | 10 ++ profiles/core/default.nix | 8 +- .../emacs/emacs.d/config/config-company.el | 1 + .../emacs/emacs.d/config/config-nix.el | 7 +- users/profiles/sway/style.css | 166 +----------------- users/profiles/zsh/default.nix | 1 + 13 files changed, 105 insertions(+), 183 deletions(-) create mode 100644 pkgs/nix-from-master/default.nix create mode 100644 profiles/cachix/ca-derivations.nix diff --git a/.gitignore b/.gitignore index 1fd1b18..7772023 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ doi pkgs/_sources/.shake* *.qcow2 + +profiles/cachix/mlabs.nix diff --git a/flake.lock b/flake.lock index f9ab66c..e91fdab 100644 --- a/flake.lock +++ b/flake.lock @@ -329,11 +329,11 @@ }, "nixpkgsDevInput": { "locked": { - "lastModified": 1650450000, - "narHash": "sha256-/ASymH28AS7KsNvkQ1RMKRoCQKSi1AsWkHdJpQwhXCg=", + "lastModified": 1650581082, + "narHash": "sha256-aq5jnmGhP0hSXYozkxUKpgSZILvDobxB976JZFG6If8=", "owner": "aciceri", "repo": "nixpkgs", - "rev": "cf941213b48d9602be0dc2656e02e065740798ab", + "rev": "24b40a255c6adc6ab32c69737e8b4cfc50d8c8b4", "type": "github" }, "original": { @@ -459,11 +459,11 @@ }, "unstable": { "locked": { - "lastModified": 1650161686, - "narHash": "sha256-70ZWAlOQ9nAZ08OU6WY7n4Ij2kOO199dLfNlvO/+pf8=", + "lastModified": 1652172129, + "narHash": "sha256-8e2JMrswaKe02P8rYfvIMoc59pNuw6h/GYu8DBE1c+0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "1ffba9f2f683063c2b14c9f4d12c55ad5f4ed887", + "rev": "f419dc5763c2b3c5580e396dea065b6d8b58ee27", "type": "github" }, "original": { diff --git a/hosts/hs/configuration.nix b/hosts/hs/configuration.nix index 8a1c66a..09f96ec 100644 --- a/hosts/hs/configuration.nix +++ b/hosts/hs/configuration.nix @@ -210,9 +210,7 @@ 'rt=$request_time uct="$upstream_connect_time" uht="$upstream_header_time" urt="$upstream_response_time"'; ''; virtualHosts = { - "torrent.ccr.ydns.eu" = { - enableACME = true; forceSSL = true; locations."/" = { @@ -252,10 +250,55 @@ proxyPass = "http://192.168.1.71:80"; }; }; + + "cam.ccr.ydns.eu" = { + enableACME = true; + addSSL = true; + locations."/" = { + proxyPass = "http://192.168.1.80:80"; + }; + }; }; }; }; + + systemd.services.ydns = + let + ydnsUpdater = pkgs.writeScriptBin "ydnsUpdater" '' + #!${pkgs.stdenv.shell} + USER="andrea.ciceri@autistici.org" + PASSWORD=$(${pkgs.stdenv}/bin/cat /home/ccr/.ydns-password) + DOMAIN="ccr.ydns.eu" + + for SUBDOMAIN in "books" "music" "sync" "torrent" "gate" "cam" + do + HOST="$SUBDOMAIN.$DOMAIN" + ${pkgs.curl}/bin/curl --basic -u "$USER:$PASSWORD" --silent https://ydns.io/api/v1/update/?host=$HOST + done + ${pkgs.curl}/bin/curl --basic -u "$USER:$PASSWORD" --silent https://ydns.io/api/v1/update/?host=$DOMAIN + ''; + in + { + description = "YDNS IP updater"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + serviceConfig = { + User = "ccr"; + Type = "oneshot"; + ExecStart = "${ydnsUpdater}/bin/ydnsUpdater"; + }; + }; + + systemd.timers.ydnsUpdater = { + wantedBy = [ "timers.target" ]; + partOf = [ "ydnsUpdater.service" ]; + timerConfig = { + OnCalendar = "*-*-* *:00:00"; # hourly + Unit = "ydnsUpdater.service"; + }; + }; + networking.firewall = { enable = true; allowPing = true; diff --git a/hosts/pc/configuration.nix b/hosts/pc/configuration.nix index 8f760b2..e1a22b8 100644 --- a/hosts/pc/configuration.nix +++ b/hosts/pc/configuration.nix @@ -38,7 +38,13 @@ fileSystems."/" = { device = "/dev/disk/by-label/nixos"; - fsType = "btrfs"; + fsType = "ext4"; + }; + + fileSystems."/home" = + { + device = "/dev/disk/by-label/home"; + fsType = "ext4"; }; swapDevices = @@ -49,15 +55,16 @@ automatic = true; options = "--delete-older-than 3d"; }; + # package = pkgs.nixFromMaster; + package = pkgs.nix; # currently from unstable through an overlay + extraOptions = '' + experimental-features = ca-derivations + ''; }; - networking.firewall = { enable = true; allowPing = true; - allowedTCPPorts = [ - 5900 # vnc - ]; }; # TODO: disable, only for playing diff --git a/pkgs/default.nix b/pkgs/default.nix index 6948e7c..5f590e1 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -17,7 +17,7 @@ in customEmacs = prev.callPackage (import ./emacs) { }; amule = prev.callPackage (import ./amule) { }; digikam = nixpkgsUnstable.digikam; - cura = nixpkgsUnstable.cura; + #cura = nixpkgsUnstable.cura; qutebrowser = import ./qutebrowser { pkgs = prev; }; #firefox-unwrapped = nixpkgsUnstable.firefox-unwrapped; xdg-desktop-portal = nixpkgsUnstable.xdg-desktop-portal; @@ -30,5 +30,7 @@ in v4l2loopback-dc = prev.callPackage (import ./v4l2loopback-dc) { kernel = prev.linux; }; slack = import ./slack { pkgs = prev; }; google-chrome = import ./google-chrome { pkgs = prev; }; + nixFromMaster = import ./nix-from-master { nix = nixpkgsUnstable.nix; pkgs = prev; }; + nix = nixpkgsUnstable.nix; # then, call packages with `final.callPackage` } diff --git a/pkgs/emacs/default.nix b/pkgs/emacs/default.nix index b027dda..df0263c 100644 --- a/pkgs/emacs/default.nix +++ b/pkgs/emacs/default.nix @@ -12,6 +12,7 @@ emacsWithPackages ( aggressive-indent all-the-icons company + company-nixos-options dap-mode diff-hl envrc @@ -25,6 +26,7 @@ emacsWithPackages ( helm helm-ag helm-company + helm-nixos-options helm-projectile lispy lsp-haskell @@ -34,6 +36,8 @@ emacsWithPackages ( magit magit-delta nix-mode + nix-modeline + nixos-options notmuch org-download org-fragtog diff --git a/pkgs/nix-from-master/default.nix b/pkgs/nix-from-master/default.nix new file mode 100644 index 0000000..9238be3 --- /dev/null +++ b/pkgs/nix-from-master/default.nix @@ -0,0 +1,9 @@ +{ nix, pkgs }: +nix.overrideAttrs (old: { + src = pkgs.fetchFromGitHub { + owner = "NixOS"; + repo = "nix"; + rev = "3ec979fa902c49e975a9af7dc2792fb197030e04"; + hash = "sha256-mpFR1OrjayyVe8LpxJVaTLVIPPeTSIu7SDz/wXP78Vg="; + }; +}) diff --git a/profiles/cachix/ca-derivations.nix b/profiles/cachix/ca-derivations.nix new file mode 100644 index 0000000..a0dd9eb --- /dev/null +++ b/profiles/cachix/ca-derivations.nix @@ -0,0 +1,10 @@ +{ + nix = { + binaryCaches = [ + "https://cache.ngi0.nixos.org/" + ]; + binaryCachePublicKeys = [ + "cache.ngi0.nixos.org-1:KqH5CBLNSyX184S9BKZJo1LxrxJ9ltnY2uAs5c/f1MA=" + ]; + }; +} diff --git a/profiles/core/default.nix b/profiles/core/default.nix index 5c0ef1e..1c56d61 100644 --- a/profiles/core/default.nix +++ b/profiles/core/default.nix @@ -8,6 +8,8 @@ in environment = { systemPackages = with pkgs; [ + bat + bat-extras.batman binutils coreutils curl @@ -58,12 +60,6 @@ in useSandbox = true; allowedUsers = [ "@wheel" ]; trustedUsers = [ "root" "@wheel" ]; - extraOptions = '' - min-free = 536870912 - keep-outputs = true - keep-derivations = true - fallback = true - ''; }; services.earlyoom.enable = true; diff --git a/users/profiles/emacs/emacs.d/config/config-company.el b/users/profiles/emacs/emacs.d/config/config-company.el index c2b9b88..3a4ca42 100644 --- a/users/profiles/emacs/emacs.d/config/config-company.el +++ b/users/profiles/emacs/emacs.d/config/config-company.el @@ -2,6 +2,7 @@ :init (setq company-backends '(company-capf company-keywords + company-nixos-options company-semantic company-files company-etags diff --git a/users/profiles/emacs/emacs.d/config/config-nix.el b/users/profiles/emacs/emacs.d/config/config-nix.el index 8fea505..0a82735 100644 --- a/users/profiles/emacs/emacs.d/config/config-nix.el +++ b/users/profiles/emacs/emacs.d/config/config-nix.el @@ -1,7 +1,10 @@ (use-package nix-mode :mode "\\.nix\\'" - :hook - (before-save . lsp-format-buffer)) + ;;:hook + ;;(before-save . lsp-format-buffer) + ) + + (require 'sudo-utils) (defun nixos-rebuild-switch () diff --git a/users/profiles/sway/style.css b/users/profiles/sway/style.css index 5a81a82..5e3bf32 100644 --- a/users/profiles/sway/style.css +++ b/users/profiles/sway/style.css @@ -1,9 +1,6 @@ * { border: none; - border-radius: 5; - /* `otf-font-awesome` is required to be installed for icons */ - /* font matches sway-config.nix */ - font-family: "DejaVu Sans"; + font-family: "Fira Code"; font-weight: bold; font-size: 9pt; min-height: 0; @@ -17,40 +14,23 @@ window#waybar { transition-duration: .5s; } +window .modules-right * { + margin: 0 1rem; +} + window#waybar.hidden { opacity: 0.2; } -/* -window#waybar.empty { - background-color: transparent; -} -window#waybar.solo { - background-color: #FFFFFF; -} -*/ - -window#waybar.termite { - background-color: #3F3F3F; -} - -window#waybar.chromium { - background-color: #000000; - border: none; -} - #workspaces button { padding: 0 5px; background-color: transparent; color: #ffffff; - border-bottom: 3px solid transparent; } /* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ #workspaces button:hover { background: rgba(0, 0, 0, 0.2); - box-shadow: inherit; - border-bottom: 3px solid #ffffff; } #workspaces button.current_output { @@ -69,44 +49,7 @@ window#waybar.chromium { background-color: #eb4d4b; } -#mode { - background-color: #64727D; - border-bottom: 3px solid #ffffff; -} -#clock, -#battery, -#cpu, -#memory, -#temperature, -#backlight, -#network, -#pulseaudio, -#custom-media, -.srht-failed, -.srht-success, -#tray, -#mode, -#idle_inhibitor, -#mpd { - padding: 0 10px; - margin: 0 4px; - color: #ffffff; -} - -#clock { - background-color: #000000; -} - -#battery { - background-color: #ffffff; - color: #000000; -} - -#battery.charging { - color: #ffffff; - background-color: #26A65B; -} @keyframes blink { to { @@ -115,105 +58,6 @@ window#waybar.chromium { } } -#battery.critical:not(.charging) { - background-color: #f53c3c; - color: #ffffff; - animation-name: blink; - animation-duration: 0.5s; - animation-timing-function: linear; - animation-iteration-count: infinite; - animation-direction: alternate; -} - label:focus { background-color: #000000; } - -#cpu { - background-color: #06989A; -} - -#memory { - background-color: #2980b9; -} - -#backlight { - background-color: #555753; -} - -#network { - background-color: #4E9A06; -} - -#network.disconnected { - background-color: #f53c3c; -} - -#pulseaudio { - background-color: #75507B; -} - -#pulseaudio.muted { - background-color: #90b1b1; - color: #2a5c45; -} - -#custom-media { - background-color: #66cc99; - color: #2a5c45; - min-width: 100px; -} - -#custom-media.custom-spotify { - background-color: #66cc99; -} - -#custom-media.custom-vlc { - background-color: #ffa000; -} - -#temperature { - background-color: #f0932b; -} - -#temperature.critical { - background-color: #eb4d4b; -} - -#tray { - background-color: #C4A000; -} - -#idle_inhibitor { - background-color: #2d3436; -} - -#idle_inhibitor.activated { - background-color: #ecf0f1; - color: #2d3436; -} - -#mpd { - background-color: #66cc99; - color: #2a5c45; -} - -#mpd.disconnected { - background-color: #f53c3c; -} - -#mpd.stopped { - background-color: #90b1b1; -} - -#mpd.paused { - background-color: #51a37a; -} - -.srht-success { - background-color: #4E9A06; -} - -.srht-failed { - background-color: #f53c3c; -} diff --git a/users/profiles/zsh/default.nix b/users/profiles/zsh/default.nix index f4e946c..382229d 100644 --- a/users/profiles/zsh/default.nix +++ b/users/profiles/zsh/default.nix @@ -41,6 +41,7 @@ "pass-clone" = "[ -d .password-store ] && echo 'Password store archive already exists' || git clone git@git.sr.ht:~zrsk/pass ~/.password-store"; "getpass" = "pass show $(find .password-store/ -name \"*.gpg\" | sed \"s/\\.password-store\\/\\(.*\\)\\.gpg$/\\1/g\" | fzf) | wl-copy; ((sleep 60 && wl-copy --clear) &)"; "cat" = "bat"; + "man" = "batman"; "em" = "[[ -z \$XDG_CURRENT_DESKTOP ]] && emacsclient -c -nw || emacsclient -c"; "emw" = "emacsclient -c"; "emnw" = "emacsclient -c -nw";