diff options
author | Linnnus <[email protected]> | 2024-02-13 17:27:18 +0100 |
---|---|---|
committer | Linnnus <[email protected]> | 2024-02-13 17:27:18 +0100 |
commit | bbbdbd1094f1f09b8075da88f6b412d2e4af80ca (patch) | |
tree | be62e8cf55aa8546068eb1bb93257a3f60280ad2 | |
parent | a908af9a955e64828f0b4f0c3b1c5770775c9794 (diff) | |
parent | 1bbdd3f63a9d8c46b1772cbf2ad9fd83d7ef213b (diff) |
tmp: Merge branch 'main' into reorg
Otherwise, we'd get a conflict when we moved duksebot.
-rw-r--r-- | home/dev-utils/default.nix | 5 | ||||
-rw-r--r-- | home/neovim/filetype.nix | 1 | ||||
-rw-r--r-- | home/neovim/lsp.nix | 19 | ||||
-rw-r--r-- | home/zsh/plugins.nix | 34 | ||||
-rw-r--r-- | modules/nixos/forsvarsarper/default.nix | 18 | ||||
-rw-r--r-- | modules/nixos/hellohtml/default.nix | 136 | ||||
-rw-r--r-- | pkgs/default.nix | 2 | ||||
-rw-r--r-- | pkgs/duksebot/default.nix | 4 | ||||
-rw-r--r-- | pkgs/pbv/default.nix | 34 |
9 files changed, 120 insertions, 133 deletions
diff --git a/home/dev-utils/default.nix b/home/dev-utils/default.nix index 67bf017..7239c28 100644 --- a/home/dev-utils/default.nix +++ b/home/dev-utils/default.nix @@ -33,7 +33,10 @@ clojure leiningen ] - ++ lib.optional pkgs.stdenv.isDarwin trash; + ++ lib.optionals pkgs.stdenv.isDarwin [ + pbv + trash + ]; # Add system manual pages to the search path on Darwin. home.sessionVariables.MANPATH = lib.optionalString pkgs.stdenv.isDarwin "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/share/man:/Applications/Xcode.app/Contents/Developer/usr/share/man:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man:$MANPATH"; diff --git a/home/neovim/filetype.nix b/home/neovim/filetype.nix index 08b5e46..cb47420 100644 --- a/home/neovim/filetype.nix +++ b/home/neovim/filetype.nix @@ -8,5 +8,6 @@ vim-noweb vim-janet vim-crystal + vim-svelte ]; } diff --git a/home/neovim/lsp.nix b/home/neovim/lsp.nix index 20de898..0c2e290 100644 --- a/home/neovim/lsp.nix +++ b/home/neovim/lsp.nix @@ -49,24 +49,7 @@ -- map buffer local keybindings when the language server attaches local servers = { pyright = { cmd = { "${pkgs.pyright}/bin/pyright-langserver", "--stdio" } }, - nil_ls = { - cmd = { "${pkgs.nil}/bin/nil" }, - settings = { - ["nil"] = { - formatting = { - command = {"nix", "run", "nixpkgs#alejandra"}, - }, - nix = { - flake = { - -- calls `nix flake archive` to put a flake and its output to store - autoArchive = true, - -- auto eval flake inputs for improved completion - autoEvalInputs = true, - }, - }, - }, - }, - }, + nixd = { cmd = { "${pkgs.nixd}/bin/nixd" } }, denols = { init_options = { enable = true, diff --git a/home/zsh/plugins.nix b/home/zsh/plugins.nix index 91cee3d..6dbc151 100644 --- a/home/zsh/plugins.nix +++ b/home/zsh/plugins.nix @@ -19,40 +19,6 @@ }; } { - name = "zsh-cwd-history"; - src = pkgs.stdenvNoCC.mkDerivation rec { - pname = "zsh-cwd-history"; - version = "73afed8"; - - src = pkgs.fetchFromGitHub { - owner = "ericfreese"; - repo = pname; - rev = version; - hash = "sha256-xW11wPFDuFU80AzgAgLwkvK7Qv58fo3i3kSasE3p0zs="; - }; - - fixupPhase = '' - substituteInPlace ${pname}.zsh \ - --replace md5 ${pkgs.hashdeep}/bin/md5deep - - mkdir -p $out - mv * $out - ''; - - # This is kind of a weird, useless derivation, so we have to - # manually avoid doing lots of the usual stuff. - dontInstall = true; - }; - config = '' - # Where to but history files - export ZSH_CWD_HISTORY_DIR=${config.xdg.dataHome}/zsh-cwd-history - mkdir -p "$ZSH_CWD_HISTORY_DIR" - - # Toggle between global/local history - bindkey '^G' cwd-history-toggle - ''; - } - { name = "zsh-vi-mode-cursor"; src = pkgs.fetchFromGitHub { owner = "Buckmeister"; diff --git a/modules/nixos/forsvarsarper/default.nix b/modules/nixos/forsvarsarper/default.nix index c7dfc90..7052f04 100644 --- a/modules/nixos/forsvarsarper/default.nix +++ b/modules/nixos/forsvarsarper/default.nix @@ -40,16 +40,14 @@ in { Group = "forsvarsarper"; WorkingDirectory = config.users.users.forsvarsarper.home; }; - script = - let - python3' = pkgs.python3.withPackages (ps: [ps.requests]); - in - '' - # Load the secret environment variables. - export $(grep -v '^#' ${config.age.secrets.forsvarsarper-env.path} | xargs) - # Kick off. - exec ${python3'}/bin/python3 ${./script.py} - ''; + script = let + python3' = pkgs.python3.withPackages (ps: [ps.requests]); + in '' + # Load the secret environment variables. + export $(grep -v '^#' ${config.age.secrets.forsvarsarper-env.path} | xargs) + # Kick off. + exec ${python3'}/bin/python3 ${./script.py} + ''; }; # Create a timer to activate our oneshot service. diff --git a/modules/nixos/hellohtml/default.nix b/modules/nixos/hellohtml/default.nix index fa25c74..cc15779 100644 --- a/modules/nixos/hellohtml/default.nix +++ b/modules/nixos/hellohtml/default.nix @@ -1,5 +1,9 @@ -{ config, lib, pkgs, ... }: - +{ + config, + lib, + pkgs, + ... +}: # FIXME: It is wasteful to always run the service. We should run on-demand instead. # This is usually achieved using SystemD sockets [4] but we are blocked on missing # features in Deno [1, 5]. @@ -19,11 +23,9 @@ # [6]: https://github.com/tokio-rs/tokio/issues/5678 # [7]: https://github.com/benoitc/gunicorn/blob/660fd8d850f9424d5adcd50065e6060832a200d4/gunicorn/arbiter.py#L142-L155 # [8]: https://github.com/linnnus/push-notification-api/tree/b9ed4071a4500a26b3b348a7f5fbc549e9694562 - let cfg = config.services.hellohtml; -in -{ +in { options.services.hellohtml = { enable = lib.mkEnableOption "hellohtml service"; @@ -43,79 +45,77 @@ in home = "/srv/hellohtml"; createHome = true; # Store DB here. }; - users.groups.hellohtml = { }; + users.groups.hellohtml = {}; # Create hellohtml service. systemd.services.hellohtml = { description = "HelloHTML server!!!"; - wantedBy = [ "multi-user.target" ]; - after = [ "network.target" ]; + wantedBy = ["multi-user.target"]; + after = ["network.target"]; - serviceConfig = - let - src = pkgs.fetchFromGitHub { - owner = "linnnus"; - repo = "hellohtml"; - rev = "97f00500712d8551d7bbf497ec442083c63384d0"; - hash = "sha256-6nbL2B26dc83F2gSLXadyfS8etuPhhlFy9ivG5l6Tog"; - }; + serviceConfig = let + src = pkgs.fetchFromGitHub { + owner = "linnnus"; + repo = "hellohtml"; + rev = "97f00500712d8551d7bbf497ec442083c63384d0"; + hash = "sha256-6nbL2B26dc83F2gSLXadyfS8etuPhhlFy9ivG5l6Tog"; + }; - hellohtml-vendor = pkgs.stdenv.mkDerivation { - name = "hellohtml-vendor"; - nativeBuildInputs = [ pkgs.unstable.deno ]; - inherit src; - buildCommand = '' - # Deno wants to create cache directories. - HOME="$(mktemp -d)" - # Thought this wasn't necessary??? - cd $src - # Build directory containing offline deps + import map. - deno vendor --output=$out ./src/server.ts - ''; - outputHashAlgo = "sha256"; - outputHashMode = "recursive"; - outputHash = "sha256-0TGLkEvJaBpI7IlTyuYRzA20Bw/TMSMz3q8wm5oPsBM"; - }; + hellohtml-vendor = pkgs.stdenv.mkDerivation { + name = "hellohtml-vendor"; + nativeBuildInputs = [pkgs.unstable.deno]; + inherit src; + buildCommand = '' + # Deno wants to create cache directories. + HOME="$(mktemp -d)" + # Thought this wasn't necessary??? + cd $src + # Build directory containing offline deps + import map. + deno vendor --output=$out ./src/server.ts + ''; + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + outputHash = "sha256-0TGLkEvJaBpI7IlTyuYRzA20Bw/TMSMz3q8wm5oPsBM"; + }; - hellohtml-drv = pkgs.writeShellScript "hellohtml" '' - export HELLOHTML_DB_PATH="${config.users.users.hellohtml.home}"/hello.db - export HELLOHTML_PORT=${toString cfg.port} - export HELLOHTML_BASE_DIR="${src}" + hellohtml-drv = pkgs.writeShellScript "hellohtml" '' + export HELLOHTML_DB_PATH="${config.users.users.hellohtml.home}"/hello.db + export HELLOHTML_PORT=${toString cfg.port} + export HELLOHTML_BASE_DIR="${src}" - ${pkgs.unstable.deno}/bin/deno run \ - --allow-read=$HELLOHTML_BASE_DIR,$HELLOHTML_DB_PATH,. \ - --allow-write=$HELLOHTML_DB_PATH \ - --allow-net=0.0.0.0:$HELLOHTML_PORT \ - --allow-env \ - --no-prompt \ - --unstable-kv \ - --import-map=${hellohtml-vendor}/import_map.json \ - --no-remote \ - ${src}/src/server.ts - ''; - in - { - Type = "simple"; - User = config.users.users.hellohtml.name; - Group = config.users.users.hellohtml.group; - ExecStart = "${hellohtml-drv}"; + ${pkgs.unstable.deno}/bin/deno run \ + --allow-read=$HELLOHTML_BASE_DIR,$HELLOHTML_DB_PATH,. \ + --allow-write=$HELLOHTML_DB_PATH \ + --allow-net=0.0.0.0:$HELLOHTML_PORT \ + --allow-env \ + --no-prompt \ + --unstable-kv \ + --import-map=${hellohtml-vendor}/import_map.json \ + --no-remote \ + ${src}/src/server.ts + ''; + in { + Type = "simple"; + User = config.users.users.hellohtml.name; + Group = config.users.users.hellohtml.group; + ExecStart = "${hellohtml-drv}"; - # Harden service - # NoNewPrivileges = "yes"; - # PrivateTmp = "yes"; - # PrivateDevices = "yes"; - # DevicePolicy = "closed"; - # ProtectControlGroups = "yes"; - # ProtectKernelModules = "yes"; - # ProtectKernelTunables = "yes"; - # RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6 AF_NETLINK"; - # RestrictNamespaces = "yes"; - # RestrictRealtime = "yes"; - # RestrictSUIDSGID = "yes"; - # MemoryDenyWriteExecute = "yes"; - # LockPersonality = "yes"; - }; + # Harden service + # NoNewPrivileges = "yes"; + # PrivateTmp = "yes"; + # PrivateDevices = "yes"; + # DevicePolicy = "closed"; + # ProtectControlGroups = "yes"; + # ProtectKernelModules = "yes"; + # ProtectKernelTunables = "yes"; + # RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6 AF_NETLINK"; + # RestrictNamespaces = "yes"; + # RestrictRealtime = "yes"; + # RestrictSUIDSGID = "yes"; + # MemoryDenyWriteExecute = "yes"; + # LockPersonality = "yes"; + }; }; }; } diff --git a/pkgs/default.nix b/pkgs/default.nix index 0a7fac8..d0efcc3 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -15,6 +15,8 @@ pkgs: { # from the repo where they spellcheck LaTex files. yalafi-shell = pkgs.callPackage ./yalafi-shell {}; + pbv = pkgs.callPackage ./pbv {}; + # TODO: These should be contained in the 'vimPlugins' attrset. This turns out # to be non-trivial because this module is both consumed in a flake output # context and an overlay context. diff --git a/pkgs/duksebot/default.nix b/pkgs/duksebot/default.nix index 17919b6..19799cb 100644 --- a/pkgs/duksebot/default.nix +++ b/pkgs/duksebot/default.nix @@ -33,8 +33,8 @@ src = fetchFromGitHub { owner = "linnnus"; repo = "duksebot"; - rev = "24634ab7459d913aea00c2e6d77f916607834ee4"; - hash = "sha256-+tbC7Z3oewBTyE6wTpUocL+6oWjCRAsqauBLTIOVBUY="; + rev = "69d45f62d1a3dce971f098dbcd5ee2b3ad0da7e5"; + hash = "sha256-4rkVnHY7WoB8A6PteulCfdlcJJJ91ez/oSatg5ujfPw="; }; in writeShellScriptBin "duksebot" diff --git a/pkgs/pbv/default.nix b/pkgs/pbv/default.nix new file mode 100644 index 0000000..7b642af --- /dev/null +++ b/pkgs/pbv/default.nix @@ -0,0 +1,34 @@ +{ + lib, + swiftPackages, + fetchFromGitHub, +}: +swiftPackages.stdenv.mkDerivation { + pname = "pbv"; + version = "31-08-2020"; # date of commit + + src = fetchFromGitHub { + owner = "chbrown"; + repo = "macos-pasteboard"; + rev = "6d58ddcff833397b15f4435e661fc31a1ec91321"; + hash = "sha256-6QpvIPy259d7BtA6s2NxS5JqiBPngPwgVgJl509btuY="; + }; + + buildInputs = [ + swiftPackages.swift + swiftPackages.xcbuild + swiftPackages.apple_sdk.frameworks.Cocoa + ]; + + installPhase = '' + mkdir -p $out/bin + make prefix=$out install + ''; + + meta = with lib; { + description = "Like OS X's built-in pbpaste but more flexible and raw"; + homepage = "https://github.com/chbrown/macos-pasteboard"; + license = licenses.mit; + platforms = platforms.darwin; + }; +} |