diff --git a/.envrc b/.envrc index 4a7aad1..afd3614 100644 --- a/.envrc +++ b/.envrc @@ -1,2 +1,2 @@ -nix_direnv_watch_file utils/default.nix +nix_direnv_watch_file flake.nix utils/default.nix use flake diff --git a/doom.d/config.el b/doom.d/config.el index e02a5e0..9ab417d 100644 --- a/doom.d/config.el +++ b/doom.d/config.el @@ -77,7 +77,7 @@ (setenv "SSH_AUTH_SOCK" "/run/user/1000/gnupg/S.gpg-agent.ssh") -(set-formatter! 'nix-flake "nixFormat 2>/dev/null" :modes '(nix-mode)) +(set-formatter! 'nix-smart-formatter "nixFormat ." :modes '(nix-mode)) (defun doom-modeline-set-vcs-modeline () nil) ; FIXME diff --git a/flake.lock b/flake.lock index 52fcb53..cfbcaf1 100644 --- a/flake.lock +++ b/flake.lock @@ -18,27 +18,6 @@ "type": "github" } }, - "androidPkgs": { - "inputs": { - "devshell": "devshell", - "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_5" - }, - "locked": { - "lastModified": 1638562808, - "narHash": "sha256-nnGyBugMQo9WweTgpfPbJu0fHnRtxvsPQ9el2D3wPrY=", - "owner": "tadfisher", - "repo": "android-nixpkgs", - "rev": "a191ab6adb019b09d3bb919bb98dca31d83519d5", - "type": "github" - }, - "original": { - "owner": "tadfisher", - "ref": "stable", - "repo": "android-nixpkgs", - "type": "github" - } - }, "comma": { "inputs": { "flake-compat": "flake-compat", @@ -60,21 +39,6 @@ "type": "github" } }, - "devshell": { - "locked": { - "lastModified": 1637575296, - "narHash": "sha256-ZY8YR5u8aglZPe27+AJMnPTG6645WuavB+w0xmhTarw=", - "owner": "numtide", - "repo": "devshell", - "rev": "0e56ef21ba1a717169953122c7415fa6a8cd2618", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "devshell", - "type": "github" - } - }, "doom-emacs": { "flake": false, "locked": { @@ -342,21 +306,6 @@ "type": "github" } }, - "flake-utils_3": { - "locked": { - "lastModified": 1638122382, - "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "74f7e4319258e287b0f9cb95426c9853b282730b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "format-all": { "flake": false, "locked": { @@ -496,22 +445,6 @@ "type": "github" } }, - "nixpkgsUnstable_2": { - "locked": { - "lastModified": 1638376152, - "narHash": "sha256-ucgLpVqhFnClH7YRUHBHnmiOd82RZdFR3XJt36ks5fE=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "6daa4a5c045d40e6eae60a3b6e427e8700f1c07f", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs_2": { "locked": { "lastModified": 1663235518, @@ -557,38 +490,6 @@ "type": "indirect" } }, - "nixpkgs_5": { - "locked": { - "lastModified": 1637841632, - "narHash": "sha256-QYqiKHdda0EOnLGQCHE+GluD/Lq2EJj4hVTooPM55Ic=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "73369f8d0864854d1acfa7f1e6217f7d6b6e3fa1", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_6": { - "locked": { - "lastModified": 1638371214, - "narHash": "sha256-0kE6KhgH7n0vyuX4aUoGsGIQOqjIx2fJavpCWtn73rc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "a640d8394f34714578f3e6335fc767d0755d78f9", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-21.11", - "repo": "nixpkgs", - "type": "github" - } - }, "nose": { "flake": false, "locked": { @@ -720,27 +621,6 @@ "type": "github" } }, - "robotnix": { - "inputs": { - "androidPkgs": "androidPkgs", - "nixpkgs": "nixpkgs_6", - "nixpkgsUnstable": "nixpkgsUnstable_2" - }, - "locked": { - "lastModified": 1665920835, - "narHash": "sha256-FBe55Yz8q8lcgq5H/yClqeen7bTZtNGom6UAdAP+Pvg=", - "owner": "atemu", - "repo": "robotnix", - "rev": "dd7e83fb19c7ef7eb87d21ceb07fb44d84ddbd57", - "type": "github" - }, - "original": { - "owner": "atemu", - "ref": "update/lineageos", - "repo": "robotnix", - "type": "github" - } - }, "root": { "inputs": { "agenix": "agenix", @@ -750,8 +630,7 @@ "nixosHardware": "nixosHardware", "nixpkgsStable": "nixpkgsStable", "nixpkgsUnstable": "nixpkgsUnstable", - "preCommitHooks": "preCommitHooks", - "robotnix": "robotnix" + "preCommitHooks": "preCommitHooks" } }, "rotate-text": { diff --git a/flake.nix b/flake.nix index c0921aa..7682c75 100644 --- a/flake.nix +++ b/flake.nix @@ -13,7 +13,6 @@ agenix.url = github:ryantm/agenix; doomEmacs.url = github:nix-community/nix-doom-emacs; comma.url = github:nix-community/comma; - robotnix.url = github:atemu/robotnix/update/lineageos; }; outputs = {self, ...} @ inputs: let @@ -33,12 +32,9 @@ in { inherit nixosConfigurations; - packages = androidImages; - apps = lib.foldr lib.recursiveUpdate {} [ (mkVmApps self.nixosConfigurations) formatApp - androidGenerateKeysScripts ]; checks = checkFormatting ./.; diff --git a/hmModules/emacs/default.nix b/hmModules/emacs/default.nix index 46ae36e..1f7fc2e 100644 --- a/hmModules/emacs/default.nix +++ b/hmModules/emacs/default.nix @@ -28,28 +28,28 @@ --replace '(emacs-repository-get-branch)' '"master"' '' + (lib.optionalString (old ? NATIVE_FULL_AOT) - # TODO: remove when https://github.com/NixOS/nixpkgs/pull/193621 is merged - ( - let - backendPath = - lib.concatStringsSep " " - (builtins.map (x: ''\"-B${x}\"'') [ - # Paths necessary so the JIT compiler finds its libraries: - "${lib.getLib pkgs.libgccjit}/lib" - "${lib.getLib pkgs.libgccjit}/lib/gcc" - "${lib.getLib pkgs.stdenv.cc.libc}/lib" + # TODO: remove when https://github.com/NixOS/nixpkgs/pull/193621 is merged + ( + let + backendPath = + lib.concatStringsSep " " + (builtins.map (x: ''\"-B${x}\"'') [ + # Paths necessary so the JIT compiler finds its libraries: + "${lib.getLib pkgs.libgccjit}/lib" + "${lib.getLib pkgs.libgccjit}/lib/gcc" + "${lib.getLib pkgs.stdenv.cc.libc}/lib" - # Executable paths necessary for compilation (ld, as): - "${lib.getBin pkgs.stdenv.cc.cc}/bin" - "${lib.getBin pkgs.stdenv.cc.bintools}/bin" - "${lib.getBin pkgs.stdenv.cc.bintools.bintools}/bin" - ]); - in '' - substituteInPlace lisp/emacs-lisp/comp.el --replace \ - "(defcustom comp-libgccjit-reproducer nil" \ - "(setq native-comp-driver-options '(${backendPath})) (defcustom comp-libgccjit-reproducer nil" - '' - )); + # Executable paths necessary for compilation (ld, as): + "${lib.getBin pkgs.stdenv.cc.cc}/bin" + "${lib.getBin pkgs.stdenv.cc.bintools}/bin" + "${lib.getBin pkgs.stdenv.cc.bintools.bintools}/bin" + ]); + in '' + substituteInPlace lisp/emacs-lisp/comp.el --replace \ + "(defcustom comp-libgccjit-reproducer nil" \ + "(setq native-comp-driver-options '(${backendPath})) (defcustom comp-libgccjit-reproducer nil" + '' + )); }); in { programs.emacs = { @@ -86,17 +86,22 @@ in { }; home.packages = with pkgs; let - path = pkgs.lib.makeBinPath (with pkgs; [ + path = pkgs.lib.makeBinPath [ + git + jq nix nixpkgs-fmt - git - ]); + ]; nixFormat = writeScriptBin "nixFormat" '' export PATH=${pkgs.lib.escapeShellArg path} - if [[ ! "$(nix fmt $@)" ]] + customFormatter=$(nix flake show --no-write-lock-file --no-update-lock-file --json | jq 'has("formatter")') + + if [[ $customFormatter == "true" ]] then - nixpkgs-fmt $@ + nix fmt <<< /dev/stdin + else + nixpkgs-fmt <<< /dev/stdin fi ''; in [ diff --git a/hmModules/mopidy/default.nix b/hmModules/mopidy/default.nix new file mode 100644 index 0000000..fa2ebcb --- /dev/null +++ b/hmModules/mopidy/default.nix @@ -0,0 +1,64 @@ +# TODO: use upstream ytmusic when updated: https://github.com/OzymandiasTheGreat/mopidy-ytmusic/issues/68 +{pkgs, ...}: let + ytmusicapi = pkgs.python310Packages.buildPythonPackage rec { + pname = "ytmusicapi"; + version = "0.24.0"; + format = "pyproject"; + src = pkgs.python310Packages.fetchPypi { + inherit pname version; + hash = "sha256-vbSWgBze3tFLEpHdh3JXij3m5R6iAhTSjrCMaSLZalY="; + }; + nativeBuildInputs = with pkgs.python310Packages; [ + setuptools + setuptools-scm + ]; + propagatedBuildInputs = with pkgs.python310Packages; [ + requests + ]; + }; + + mopidy-ytmusic = pkgs.python310Packages.buildPythonApplication rec { + pname = "mopidy-ytmusic"; + version = "0.3.5"; + + src = pkgs.python3Packages.fetchPypi { + inherit version; + pname = "Mopidy-YTMusic"; + sha256 = "0pncyxfqxvznb9y4ksndbny1yf5mxh4089ak0yz86dp2qi5j99iv"; + }; + + postPatch = '' + substituteInPlace setup.py \ + --replace 'ytmusicapi>=0.20.0,<0.21.0' 'ytmusicapi>=0.20.0' + ''; + + propagatedBuildInputs = with pkgs; [ + mopidy + ytmusicapi + python310Packages.pytube + ]; + + pythonImportsCheck = ["mopidy_ytmusic"]; + + doCheck = false; + }; +in { + services.mopidy = { + enable = true; + extensionPackages = [mopidy-ytmusic] ++ (with pkgs; [mopidy-mpd mopidy-mpris]); + settings = { + mpd = { + enabled = true; + hostname = "127.0.0.1"; + port = 6600; + # password = ""; + max_connections = 20; + connection_timeout = 60; + # zeroconf = "Mopidy MPD server on $hostname"; + }; + # youtube = { + # enabled = true; + # }; + }; + }; +} diff --git a/hmModules/qutebrowser/default.nix b/hmModules/qutebrowser/default.nix index aadf46b..7f541ca 100644 --- a/hmModules/qutebrowser/default.nix +++ b/hmModules/qutebrowser/default.nix @@ -2,11 +2,25 @@ pkgs, config, ... -}: { +}: let + settings = config.programs.qutebrowser.settings; + websites = { + searx = "https://searx.be"; + }; + colors = { + black = "#000000"; + darker-gray = "#222222"; + lighter-gray = "#333333"; + white = "#ffffff"; + dark-white = "#aaaaaa"; + less-dark-white = "#cccccc"; + blue = "#0000ff"; + }; +in { programs.qutebrowser = { enable = true; - searchEngines = { - DEFAULT = "https://searx.be/search?q={}&category_general=on&language=all"; + searchEngines = with websites; { + DEFAULT = "${searx}/search?q={}&category_general=on&language=all"; w = "https://en.wikipedia.org/wiki/Special:Search?search={}&go=Go&ns0=1"; np = "https://search.nixos.org/packages?sort=relevance&type=packages&query={}"; no = "https://search.nixos.org/options?sort=relevance&type=options&query={}"; @@ -18,23 +32,27 @@ normal = { "" = "spawn mpv --force-window=immediate {url}"; ",l" = ''config-cycle spellcheck.languages [" it-IT "] [" en-US "]''; - "" = "spawn --userscript qute-pass --dmenu-invocation 'fuzzel -d'"; - "" = "spawn --userscript qute-pass --dmenu-invocation 'fuzzel -d' --username-only"; - "

" = "spawn --userscript qute-pass --dmenu-invocation 'fuzzel -d' --password-only"; - "" = "spawn --userscript qute-pass --dmenu-invocation 'fuzzel -d' --otp-only"; + }; + insert = { + "" = ''spawn --userscript qute-pass --dmenu-invocation '${pkgs.fuzzel}/bin/fuzzel --background-color=253559cc --border-radius=5 --border-width=0 -d' --password-only --unfiltered''; }; }; settings = { auto_save.session = true; - url.start_pages = ["https://searx.be"]; + url = with websites; { + default_page = searx; + start_pages = [searx]; + }; editor.command = [ "emacsclient" "+{line}:{column}" "{file}" "-c" + "-F" + "'(name . \\\"{file} - editor - qutebrowser\\\"))" # this is needed to keep the Emacs frame in the correct Sway workspace ]; content.pdfjs = true; - scrolling.smooth = true; + scrolling.smooth = false; fonts = { default_size = "11pt"; tabs = { @@ -42,15 +60,38 @@ unselected = "13pt"; }; }; - colors = { + colors = with colors; { + webpage.bg = black; # to avoid flashes when opening new tabs tabs = { even = { - bg = "silver"; - fg = "#666666"; + bg = darker-gray; + fg = dark-white; }; odd = { - bg = "gainsboro"; - fg = config.programs.qutebrowser.settings.colors.tabs.even.fg; + bg = lighter-gray; + fg = settings.colors.tabs.even.fg; + }; + }; + completion = { + even.bg = darker-gray; + odd.bg = settings.colors.completion.even.bg; + fg = less-dark-white; + # match.fg = ""; + item.selected = { + match.fg = blue; + # bg = ""; + # fg = ""; + border = { + top = settings.colors.completion.even.bg; + bottom = settings.colors.completion.even.bg; + }; + }; + category = { + bg = lighter-gray; + border = { + top = settings.colors.completion.even.bg; + bottom = settings.colors.completion.even.bg; + }; }; }; }; diff --git a/hmModules/shell/default.nix b/hmModules/shell/default.nix index 0c238fc..a7b3f2c 100644 --- a/hmModules/shell/default.nix +++ b/hmModules/shell/default.nix @@ -80,5 +80,9 @@ ''; }; - home.packages = with pkgs; [thefuck htop-vim dig.dnsutils]; + home.packages = with pkgs; [ + thefuck + htop-vim + dig.dnsutils + ]; } diff --git a/hmModules/sway/default.nix b/hmModules/sway/default.nix index 5fd6b00..487bf42 100644 --- a/hmModules/sway/default.nix +++ b/hmModules/sway/default.nix @@ -52,7 +52,6 @@ inherit bg; }; }; - #fonts = [ "Font Awesome" "Fira Code" ]; terminal = "footclient"; bars = [ { @@ -61,7 +60,7 @@ ]; assigns = { "1" = [{title = ".*Mozilla Firefox$";} {title = ".*qutebrowser$";}]; - "2" = [{title = ".*Emacs$";}]; + "2" = [{title = "^((?!qutebrowser-editor).)*Emacs$";}]; "3" = [{title = "Slack.*";}]; "8" = [{title = "^Franz$";}]; "9" = [{title = "^Element.*";}]; @@ -69,6 +68,7 @@ floating.criteria = [ {title = "MetaMask Notification.*";} {title = "Volume Control";} # pavucontrol + {title = "^.*editor - qutebrowser$";} # Emacs opened by qutebrowser ]; input = { "*" = { @@ -80,14 +80,21 @@ screenshotScript = pkgs.writeShellScript "screenshot.sh" '' filename="$HOME/shots/$(date --iso-8601=seconds).png" coords="$(${pkgs.slurp}/bin/slurp)" - ${pkgs.grim}/bin/grim -t png -g "$coords" $filename + ${pkgs.grim}/bin/grim -t png -g "$coords" "$filename" wl-copy -t image/png < $filename ''; + screenrecordingScript = pkgs.writeShellScript "screenrecorder.sh" '' + filename="$HOME/shots/recording-$(date --iso-8601=seconds).mp4" + coords="$(${pkgs.slurp}/bin/slurp)" + ${pkgs.wf-recorder}/bin/wf-recorder -g "$coords" -f "$filename" + wl-copy -t video/mp4 < $filename + ''; in lib.mkOptionDefault { "${modifier}+x" = "exec emacsclient -c"; "${modifier}+b" = "exec qutebrowser"; "${modifier}+s" = "exec ${screenshotScript}"; + "${modifier}+g" = "exec ${screenrecordingScript}"; "XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s +5%"; "XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s 5%-"; }; diff --git a/hmModules/xdg/default.nix b/hmModules/xdg/default.nix index 1dac606..2d5d8b6 100644 --- a/hmModules/xdg/default.nix +++ b/hmModules/xdg/default.nix @@ -1,3 +1,4 @@ { xdg.enable = true; + xdg.mimeApps.enable = true; } diff --git a/hosts/thinkpad/default.nix b/hosts/thinkpad/default.nix index 0f336af..2f8bdb3 100644 --- a/hosts/thinkpad/default.nix +++ b/hosts/thinkpad/default.nix @@ -44,6 +44,7 @@ "git" "gpg" "helix" + "mopidy" "mpv" "password-store" "qutebrowser" diff --git a/modules/nix/default.nix b/modules/nix/default.nix index 156cfea..e0408f1 100644 --- a/modules/nix/default.nix +++ b/modules/nix/default.nix @@ -17,14 +17,12 @@ "mlabs.cachix.org-1:gStKdEqNKcrlSQw5iMW6wFCj3+b+1ASpBVY2SYuNV2M=" "aciceri-fleet.cachix.org-1:e1AodrwmzRWy0eQi3lUY71M41fp9Sq+UpuKKv705xsI=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - "robotnix.cachix.org-1:+y88eX6KTvkJyernp1knbpttlaLTboVp4vq/b24BIv0=" ]; substituters = [ "https://cache.iog.io" "https://mlabs.cachix.org" "https://aciceri-fleet.cachix.org" "https://nix-community.cachix.org" - "https://robotnix.cachix.org" ]; }; diff --git a/modules/xdg/default.nix b/modules/xdg/default.nix index ac77a54..a7988cf 100644 --- a/modules/xdg/default.nix +++ b/modules/xdg/default.nix @@ -6,8 +6,12 @@ xdg-desktop-portal-wlr xdg-desktop-portal-gtk ]; - gtkUsePortal = true; }; }; + services.pipewire.enable = true; + + environment.sessionVariables = { + GTK_USE_PORTAL = "1"; + }; } diff --git a/utils/default.nix b/utils/default.nix index 03a0dab..5a24974 100644 --- a/utils/default.nix +++ b/utils/default.nix @@ -1,12 +1,12 @@ { - nixpkgsUnstable, - nixosHardware, - preCommitHooks, - homeManager, - doomEmacs, agenix, comma, - robotnix, + doomEmacs, + homeManager, + nixosHardware, + nixpkgsUnstable, + preCommitHooks, + self, ... }: let supportedSystems = { @@ -16,11 +16,9 @@ pkgsFor = lib.genAttrs (lib.attrValues supportedSystems) (system: nixpkgsUnstable.legacyPackages.${system}); - lib = nixpkgsUnstable.lib.extend (self: super: - { - perSystem = super.genAttrs (super.attrValues supportedSystems); - } - // robotnix.lib); + lib = nixpkgsUnstable.lib.extend (self: super: { + perSystem = super.genAttrs (super.attrValues supportedSystems); + }); mkConfiguration = { name, @@ -73,40 +71,6 @@ }; }; - mkAndroidConfiguration = { - name, - device, - flavor, - androidVersion, - }: - lib.robotnixSystem { - inherit device flavor; - imports = [ - (../hosts + "/${name}") - ]; - }; - - androidConfigurations = { - oneplus5t = mkAndroidConfiguration { - name = "oneplus5t"; - device = "dumpling"; - flavor = "lineageos"; - androidVersion = 12; - }; - }; - - androidImages = lib.perSystem (system: builtins.mapAttrs (confName: conf: conf.img) androidConfigurations); - - androidGenerateKeysScripts = lib.perSystem (system: - lib.mapAttrs' (confName: conf: { - name = "${confName}-generateKeys"; - value = { - type = "app"; - program = "${conf.generateKeysScript}"; - }; - }) - androidConfigurations); - mkVmApp = system: configuration: let shellScript = pkgsFor.${system}.writeShellScript "run-vm" '' ${configuration.config.system.build.vm}/bin/run-${configuration.config.networking.hostName}-vm @@ -146,8 +110,11 @@ checkFormattingHook = lib.perSystem ( system: { nix = preCommitHooks.lib.${system}.run { - src = ./.; - hooks.alejandra.enable = true; + src = self; + hooks.alejandra = { + enable = true; + entry = lib.mkForce formatApp.${system}.format.program; + }; }; } ); @@ -169,8 +136,6 @@ }); in { inherit - androidGenerateKeysScripts - androidImages checkFormatting formatApp formatter