summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Vink <mike1994vink@gmail.com>2023-10-11 16:40:00 +0000
committerMike Vink <mike1994vink@gmail.com>2023-10-11 16:40:00 +0000
commita4d82f2fc56a7b0c3dc84dc61cd074f94dfce62f (patch)
tree67a9f4bbcc8e6edafc06197f38e04b95653144df
parent63aae9abf1f83a41ba92a4672277ba04c3bd48bf (diff)
move impure stuff
-rw-r--r--machines/wsl.nix116
-rw-r--r--mut/neovim/fnl/conf/init.fnl41
-rw-r--r--secrets/new20
3 files changed, 137 insertions, 40 deletions
diff --git a/machines/wsl.nix b/machines/wsl.nix
index 6616489..8cc81c3 100644
--- a/machines/wsl.nix
+++ b/machines/wsl.nix
@@ -1,19 +1,119 @@
{ inputs, config, lib, pkgs, ... }:
+with builtins; with lib;
+let
+ defaultConfig = pkgs.writeText "default-configuration.nix" ''
+ { config, lib, pkgs, ... }:
+
+ {
+ imports = [
+ # include NixOS-WSL modules
+ <nixos-wsl/modules>
+ ];
+
+ wsl.enable = true;
+ wsl.defaultUser = "nixos";
+ ${lib.optionalString (!cfg.nativeSystemd) "wsl.nativeSystemd = false;"}
+
+ # This value determines the NixOS release from which the default
+ # settings for stateful data, like file locations and database versions
+ # on your system were taken. It's perfectly fine and recommended to leave
+ # this value at the release version of the first install of this system.
+ # Before changing this value read the documentation for this option
+ # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
+ system.stateVersion = "${config.system.nixos.release}"; # Did you read the comment?
+ }
+ '';
+in
{
- imports = [
- inputs.nixos-wsl.nixosModules.default
- ];
+ imports = [
+ inputs.nixos-wsl.nixosModules.default
+ ];
+
+ # These options make no sense without the wsl-distro module anyway
+ config = {
+ wsl = {
+ enable = true;
+ defaultUser = "mike";
+ wslConf.network = {
+ generateResolvConf = true;
+ };
+ };
+
+ system.build.tarballBuilder = pkgs.writeShellApplication {
+ name = "nixos-wsl-tarball-builder";
+
+ runtimeInputs = [
+ pkgs.coreutils
+ pkgs.gnutar
+ pkgs.nixos-install-tools
+ config.nix.package
+ ];
+
+ text = ''
+ if ! [ $EUID -eq 0 ]; then
+ echo "This script must be run as root!"
+ exit 1
+ fi
+
+ out=''${1:-nixos-wsl.tar.gz}
+
+ root=$(mktemp -p "''${TMPDIR:-/tmp}" -d nixos-wsl-tarball.XXXXXXXXXX)
+ # FIXME: fails in CI for some reason, but we don't really care because it's CI
+ trap 'rm -rf "$root" || true' INT TERM EXIT
+
+ chmod o+rx "$root"
+
+ echo "[NixOS-WSL] Installing..."
+ nixos-install \
+ --root "$root" \
+ --no-root-passwd \
+ --system ${config.system.build.toplevel} \
+ --substituters ""
+
+ echo "[NixOS-WSL] Adding channel..."
+ nixos-enter --root "$root" --command 'nix-channel --add https://github.com/nix-community/NixOS-WSL/archive/refs/heads/main.tar.gz nixos-wsl'
+
+ echo "[NixOS-WSL] Adding default config..."
+ install -Dm644 ${defaultConfig} "$root/etc/nixos/configuration.nix"
+
+ echo "[NixOS-WSL] Compressing..."
+ tar -C "$root" \
+ -cz \
+ --sort=name \
+ --mtime='@1' \
+ --owner=0 \
+ --group=0 \
+ --numeric-owner \
+ . \
+ > "$out"
+ '';
+ };
environment.systemPackages = with pkgs; [
git
];
- wsl = {
+ system.stateVersion = "23.05";
+ virtualisation.docker = {
enable = true;
- defaultUser = "mike";
- wslConf.network.generateResolvConf = false;
+ autoPrune = {
+ enable = true;
+ flags = ["-af"];
+ };
};
- system.stateVersion = "23.05";
- virtualisation.docker.enable = true;
+ systemd.services.docker.serviceConfig = {
+ ExecStart = ["" ''
+ ${pkgs.docker}/bin/dockerd --config-file=/wsl/dockerd/daemon.json
+ ''];
+ EnvironmentFile = "/wsl/dockerd/environmentfile";
+ };
+ networking.resolvconf.enable = false;
+ # TODO: why does this not work with etc."resolv.conf"??
+ environment.etc."/resolv.conf".source = "/wsl/etc/resolv.conf";
+ environment.etc."profile.local".source = "/wsl/etc/profile";
+ security.pki.certificateFiles = [
+ (/. + "/home/mike/pr-root.cer")
+ ];
+ };
}
diff --git a/mut/neovim/fnl/conf/init.fnl b/mut/neovim/fnl/conf/init.fnl
index 151f829..3b29f40 100644
--- a/mut/neovim/fnl/conf/init.fnl
+++ b/mut/neovim/fnl/conf/init.fnl
@@ -20,14 +20,26 @@
(tel.setup
{:defaults (vim.tbl_extend :force (themes.get_ivy) {})})
+(local cope #(vim.cmd (.. ":copen " (math.floor (/ vim.o.lines 2.6)))))
+
(let [map vim.keymap.set]
- (map :n :<leader>qf ":copen<cr>")
+ (map :v :y "<Plug>OSCYankVisual|gvy")
+ (map :n :<leader>qf cope)
(map :n :<leader>q<BS> ":cclose<cr>")
(map :n :<leader>ll ":lopen<cr>")
(map :n :<leader>l<BS> ":lclose<cr>")
(map :n :<M-space> ":cprev<cr>")
+ (map :n :<C-M-space> ":cprev<cr>")
(map :n :<C-space> ":cnext<cr>")
- (map :n :<C-x> ":Compile<up><c-f>")
+ (map :n :<C-x> #(do
+ (vim.fn.setreg "/" "Compile")
+ (vim.api.nvim_feedkeys
+ (vim.api.nvim_replace_termcodes
+ ":Compile<up><c-f>" true false true)
+ :n false)
+ (vim.schedule #(do
+ (map :n :/ "/Compile.* " {:buffer true})
+ (map :n :? "?Compile.* " {:buffer true})))))
(map :n :<C-e> ":Recompile<CR>")
(map :n "[q" ":cprevious<cr>")
(map :n "]q" ":cnext<cr>")
@@ -66,14 +78,15 @@
(.. l word))))
(local lines (icollect [_ l (ipairs lines)]
- (if l
+ (if (not= l "")
(prettify l))))
- (vim.fn.setqflist [] :a {: id : title : lines}))))
+ (vim.fn.setqflist [] :a {: id : title : lines})
+ (vim.cmd ":cbottom"))))
(var last_job nil)
(local job
(fn [cmd]
- (local title (table.concat cmd " "))
+ (local title cmd)
(vim.fn.setqflist [] " " {: title})
(local add2qf (qf (vim.fn.getqflist {:id 0 :title 1})))
(local id
@@ -86,24 +99,28 @@
(if data
(add2qf data)))
:on_exit (fn [id rc]
- (if (= rc 0)
- (vim.cmd ":cope")))}))
+ (set last_job.finished true)
+ (if (= rc 0)
+ (cope)))}))
(set
last_job
{: cmd
- : id})))
+ : id
+ :finished false})))
(vim.api.nvim_create_user_command
:Compile
(fn [cmd]
- (job cmd.fargs))
+ (job cmd.args))
{:nargs :* :bang true :complete :shellcmd})
(vim.api.nvim_create_user_command
:Recompile
(fn []
- (if (not= nil last_job)
- (job last_job)
- (vim.notify "nothing to recompile")))
+ (if (= nil last_job)
+ (vim.notify "nothing to recompile")
+ (if (not last_job.finished)
+ (vim.notify "Last job not finished")
+ (job last_job.cmd))))
{:bang true})
(vim.api.nvim_create_user_command
:Abort
diff --git a/secrets/new b/secrets/new
deleted file mode 100644
index f8bd2c4..0000000
--- a/secrets/new
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "data": "ENC[AES256_GCM,data:/2Q8kuOsEwmvqbDCzMSlfA==,iv:m8rEQaFQvRdPv/49jlkREEURhRSdEyCCimzsBe0I0+Y=,tag:bVyBW5Ish7yLCelx8s13Bw==,type:str]",
- "sops": {
- "kms": null,
- "gcp_kms": null,
- "azure_kv": null,
- "hc_vault": null,
- "age": [
- {
- "recipient": "age10q9wse8dh0749ffj576q775q496pycucxlla9rjdq5rd7f4csyhqqrmkk0",
- "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB4akNhZnJXWlFlekpDUlp5\ndjQ0Q0RIWUV4aTRocFIrMlZOcFRTZzBKMVVFCm5TMlErRnVYZHkrang0TkJnN1Z6\nQUhCRmF3RjNuYnRXQXlYWlUvV3VsTUEKLS0tIE8xMllXSENnSnBsdU9qdndaYm1P\nR3Q0bEVCVXFkMmhTL1JXRkxqWTczS0EKqJoH5jXbZxU83bEF2LFsuGEksx56Sztq\n8J658rzZPMbVu2TeOQkqqNy7x0qbC28LL4iZ6FmoJJi1eI+yXUX3iw==\n-----END AGE ENCRYPTED FILE-----\n"
- }
- ],
- "lastmodified": "2023-10-08T20:33:55Z",
- "mac": "ENC[AES256_GCM,data:+1iQPIAlOv45Wz8rdpqR9rFVfKk07a6WpQrJWZFY+MEENymey5wugB+m03ZS1Y4r+iHyj4AMCM09X68xSRGTmX9WantQedFj/9F1wOcYY+Fvm/jAhbJIcYFVOchn849T8bJaIqsGOZic0IeexilaJofm8HdQr4Ki7M5aHBH0fOw=,iv:JVwUzdpaTt6NlpeyWob9u/HR6VMebfmEYCKOs17rDqk=,tag:D0vu4ciENvKoFBMtWtJsUQ==,type:str]",
- "pgp": null,
- "unencrypted_suffix": "_unencrypted",
- "version": "3.8.0"
- }
-} \ No newline at end of file