From dfaa2b6248450e8c05653beae6705315cf8502ca Mon Sep 17 00:00:00 2001 From: Sebastian Moser Date: Thu, 27 Mar 2025 11:17:34 +0100 Subject: [PATCH] ... --- .gitignore | 1 + common/all.nix | 2 + common/nixos-wayland.nix | 1 - common/wsl.nix | 41 ++++++++ flake.lock | 22 ++-- flake.nix | 20 +++- hosts/acern.nix | 15 +-- hosts/fusu.nix | 47 +++++++-- hosts/lush.nix | 25 ++++- hosts/mac.nix | 2 +- hosts/main.nix | 113 ++++++++++++++++----- hosts/mosatop.nix | 62 +++++++++++ misc/my-hosts | 1 + misc/my-hosts-h | 2 + mybin/nixre | 39 ++++++- mybin/ru | 14 ++- mybin/waydroid-session-start | 1 + mybin/waydroid-session-stop | 1 + programs/bash.nix | 41 ++++++-- programs/ssh.nix | 6 +- scripts/start-wsl.bat | 2 + users/me/gui-home.nix | 7 +- users/server/{headles.nix => headless.nix} | 0 23 files changed, 380 insertions(+), 85 deletions(-) create mode 100644 common/wsl.nix create mode 100644 hosts/mosatop.nix create mode 100755 mybin/waydroid-session-start create mode 100755 mybin/waydroid-session-stop create mode 100644 scripts/start-wsl.bat rename users/server/{headles.nix => headless.nix} (100%) diff --git a/.gitignore b/.gitignore index 4b6ad01..5b9e2dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ gitignore +result diff --git a/common/all.nix b/common/all.nix index f2fb6ca..fe87dfd 100644 --- a/common/all.nix +++ b/common/all.nix @@ -36,6 +36,8 @@ users.mutableUsers = true; + nix.channel.enable = false; + # This value determines the NixOS release from which the default diff --git a/common/nixos-wayland.nix b/common/nixos-wayland.nix index 8ccf008..ada471d 100644 --- a/common/nixos-wayland.nix +++ b/common/nixos-wayland.nix @@ -60,7 +60,6 @@ (nerdfonts.override {fonts = ["Hack"];}) ]; - sound.enable = true; home-manager.users.me.services.swayosd.enable = true; services.blueman.enable = true; hardware.bluetooth.enable = true; diff --git a/common/wsl.nix b/common/wsl.nix new file mode 100644 index 0000000..782b934 --- /dev/null +++ b/common/wsl.nix @@ -0,0 +1,41 @@ + +{ pkgs, inputs, lib, ...}: +{ + imports = [ + inputs.nix-wsl.nixosModules.wsl + ]; + + wsl.enable = true; + + wsl.wslConf.user.default = lib.mkForce "me"; + wsl.interop.register = true; + + environment.systemPackages = [ + (pkgs.writeShellScriptBin "pw" '' + /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe + '' + ) + (pkgs.writeShellScriptBin "psh" '' + /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe + '' + ) + ]; + + wsl.nativeSystemd = true; + wsl.wslConf.interop.appendWindowsPath = true; + + programs.bash.loginShellInit = ""; + + services.openssh = { + enable = true; + ports = [ 2222 ]; + + settings.PasswordAuthentication = false; + settings.KbdInteractiveAuthentication = false; + settings.X11Forwarding = true; + extraConfig = '' + X11UseLocalhost no + ''; + }; + +} diff --git a/flake.lock b/flake.lock index a5780d8..292535c 100644 --- a/flake.lock +++ b/flake.lock @@ -1451,16 +1451,16 @@ ] }, "locked": { - "lastModified": 1726989464, - "narHash": "sha256-Vl+WVTJwutXkimwGprnEtXc/s/s8sMuXzqXaspIGlwM=", + "lastModified": 1739757849, + "narHash": "sha256-Gs076ot1YuAAsYVcyidLKUMIc4ooOaRGO0PqTY7sBzA=", "owner": "nix-community", "repo": "home-manager", - "rev": "2f23fa308a7c067e52dfcc30a0758f47043ec176", + "rev": "9d3d080aec2a35e05a15cedd281c2384767c2cfe", "type": "github" }, "original": { "owner": "nix-community", - "ref": "release-24.05", + "ref": "release-24.11", "repo": "home-manager", "type": "github" } @@ -2572,11 +2572,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1728888510, - "narHash": "sha256-nsNdSldaAyu6PE3YUA+YQLqUDJh+gRbBooMMekZJwvI=", + "lastModified": 1741513245, + "narHash": "sha256-7rTAMNTY1xoBwz0h7ZMtEcd8LELk9R5TzBPoHuhNSCk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a3c0b3b21515f74fd2665903d4ce6bc4dc81c77c", + "rev": "e3e32b642a31e6714ec1b712de8c91a3352ce7e1", "type": "github" }, "original": { @@ -2902,17 +2902,17 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1729275015, - "narHash": "sha256-p9+3KzsoqBVPOY7OlW+C5F0CwSWYApNKbInRb/zenfo=", + "lastModified": 1741892592, + "narHash": "sha256-ai0XSujeUYInQtp1u6TQfrTx9Vtv9bAOkK63lWcttzk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b9562c824b11473587286eb499680129c2d0d4f1", + "rev": "a531c9252bde4165e7a49244e71a57bbfa60ba93", "type": "github" }, "original": { "owner": "NixOS", + "ref": "release-24.11", "repo": "nixpkgs", - "rev": "b9562c824b11473587286eb499680129c2d0d4f1", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 0013fcd..4b57b5f 100644 --- a/flake.nix +++ b/flake.nix @@ -3,8 +3,8 @@ ################################### INPUTS ######################################### inputs = { - #nixpkgs.url = "github:NixOS/nixpkgs/release-24.11"; - nixpkgs.url = "github:NixOS/nixpkgs/b9562c824b11473587286eb499680129c2d0d4f1"; + nixpkgs.url = "github:NixOS/nixpkgs/release-24.11"; + #nixpkgs.url = "github:NixOS/nixpkgs/b9562c824b11473587286eb499680129c2d0d4f1"; #nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; @@ -20,7 +20,8 @@ }; home-manager = { - url = "github:nix-community/home-manager/release-24.05"; + url = "github:nix-community/home-manager/release-24.11"; + #url = "github:nix-community/home-manager/release-24.05"; inputs.nixpkgs.follows = "nixpkgs"; }; @@ -240,6 +241,11 @@ { top = builtins.mapAttrs (name: value: value.config.system.build.toplevel) (self.nixOnDroidConfigurations // self.nixosConfigurations); + img = builtins.mapAttrs (name: value: + # build tarball for wsl systems and sdImage for others..... + if value.config.wsl.enable then value.config.system.build.tarballBuilder else value.config.system.build.sdImage + ) (self.nixOnDroidConfigurations // self.nixosConfigurations); + # this is my nur repo, that you can import and call with pkgs nur = import ./nur.nix; @@ -408,6 +414,14 @@ ]; }; + "mosatop" = nixpkgs.lib.nixosSystem { + inherit specialArgs; + system = "x86_64-linux"; + modules = [ + ./hosts/mosatop.nix + ]; + }; + "acern-real" = nixpkgs.lib.nixosSystem { inherit specialArgs; system = "x86_64-linux"; diff --git a/hosts/acern.nix b/hosts/acern.nix index 0097d50..4efc6d9 100644 --- a/hosts/acern.nix +++ b/hosts/acern.nix @@ -1,8 +1,8 @@ { pkgs, inputs, secretsDir, ...}: { imports = [ - inputs.nix-wsl.nixosModules.wsl ../users/me/headless.nix + ../common/wsl.nix inputs.networkmanager.nixosModules.networkmanager inputs.home-manager.nixosModules.home-manager @@ -10,19 +10,6 @@ ../common/nixos-headless.nix ]; - wsl.enable = true; - - services.openssh = { - enable = true; - ports = [ 2222 ]; - - settings.PasswordAuthentication = false; - settings.KbdInteractiveAuthentication = false; - settings.X11Forwarding = true; - extraConfig = '' - X11UseLocalhost no - ''; - }; programs.bash.loginShellInit = ""; diff --git a/hosts/fusu.nix b/hosts/fusu.nix index a7462aa..4761f89 100644 --- a/hosts/fusu.nix +++ b/hosts/fusu.nix @@ -1,7 +1,10 @@ { inputs, pkgs, secretsDir, ... }: { + + #disabledModules = [ "services/databases/couchdb.nix" ]; imports = [ + #"${inputs.nixpkgs-unstable}/nixos/modules/services/databases/couchdb.nix" ../common/all.nix ../common/nixos.nix ../common/building.nix @@ -10,6 +13,7 @@ ../users/me/headless.nix ../users/root/default.nix ../users/files/headless.nix + ../users/server/headless.nix ]; # mac address for wakeonlan: 00:19:99:fd:28:23 @@ -29,8 +33,17 @@ #} #]; + + services.tailscale.enable = true; + services.resilio = { + # TODO: add the config for the share to here + enable = true; + enableWebUI = true; + httpListenAddr = "100.70.54.18"; + }; + boot.supportedFilesystems = [ "zfs" ]; boot.zfs.package = pkgs.zfs_unstable; @@ -83,6 +96,12 @@ networking.firewall.allowPing = true; networking.firewall.enable = true; + networking.firewall.interfaces."tailscale0".allowedTCPPorts = [ + 443 # couchdb for obsidian live sync https + 44444 # resilio sync + 9000 # resilio webui + ]; + services.samba.openFirewall = true; networking.firewall.allowedTCPPorts = [ @@ -154,6 +173,14 @@ }; + + ############################ couchdb for Obsidian Live sync + #services.couchdb.enable = true; + #services.couchdb.extraConfigFiles = [ "/home/files/storage/files/stuff/obsidian-live-sync/local.ini" ]; + #services.couchdb.databaseDir = "/home/files/storage/files/stuff/obsidian-live-sync/data"; + + + ############################ update ip service systemd.services.update-ip = @@ -240,16 +267,16 @@ services.samba = { enable = true; securityType = "user"; - extraConfig = '' - server role = standalone server - map to guest = bad user - usershare allow guests = yes - hosts allow = 192.168.0.0/16 - hosts deny = 0.0.0.0 - workgroup = WORKGROUP - security = user - ''; - shares = { + settings = { + global = { + "server role" = "standalone server"; + "map to guest" = "bad user"; + "usershare allow guests" = "yes"; + # "hosts allow" = "192.168.1 127.0.0.1 localhost"; + # "hosts deny" = "0.0.0.0/0"; + "workgroup" = "WORKGROUP"; + "security" = "user"; + }; files = { "valid users" = "files"; "comment" = "all my files"; diff --git a/hosts/lush.nix b/hosts/lush.nix index f6bd5d7..0720aaa 100644 --- a/hosts/lush.nix +++ b/hosts/lush.nix @@ -146,6 +146,7 @@ type = "wifi"; interface-name = "wlan0"; autoconnect = true; + autoconnect-priority = "-200"; }; wifi = { @@ -172,6 +173,7 @@ type = "wifi"; interface-name = "wlan0"; autoconnect = true; + autoconnect-priority = "-999"; }; wifi = { @@ -185,6 +187,25 @@ psk = builtins.readFile "${secretsDir}/home-wifi-password"; }; + ipv4 = { + method = "auto"; + address1 = "192.168.1.37/24"; + }; + }; + + dhcp = { + connection = { + id = "dhcp"; + uuid = "c006389a-1697-4f77-91c3-95b466f85f13"; + type = "ethernet"; + autoconnect = "false"; + interface-name = "end0"; + }; + + ethernet = { + mac-address = "DC:A6:32:CB:4D:5E"; + }; + ipv4 = { method = "auto"; }; @@ -196,11 +217,11 @@ uuid = "f55f34e3-4595-4642-b1f6-df3185bc0a04"; type = "ethernet"; autoconnect = false; - interface-name = "eth0"; + interface-name = "end0"; }; ethernet = { - mac-address = "F4:39:09:4A:DF:0E"; + mac-address = "DC:A6:32:CB:4D:5E"; }; ipv4 = { diff --git a/hosts/mac.nix b/hosts/mac.nix index 4d2dc76..ace3eda 100644 --- a/hosts/mac.nix +++ b/hosts/mac.nix @@ -119,7 +119,7 @@ in { restartIfChanged = false; serviceConfig = { - ExecStart = "${pkgs.cage}/bin/cage -d -- ${myobs}/bin/obs"; + ExecStart = "${pkgs.cage}/bin/cage -d -- ${pkgs.moonlight-qt}/bin/moonlight"; User = "root"; # ConditionPathExists = "/dev/tty0"; diff --git a/hosts/main.nix b/hosts/main.nix index 0a4e929..6013020 100644 --- a/hosts/main.nix +++ b/hosts/main.nix @@ -35,8 +35,44 @@ #services.openssh.enable = true; + + + services.sunshine = { + package = pkgs.sunshine.overrideAttrs { + src = pkgs.fetchFromGitHub { + owner = "garnacho"; + repo = "Sunshine"; + rev = "xdg-portal"; + hash = "sha256-To1vhNQxjIa5Hc+z2xo+ODSQyIH6cnI3A7Ofc7MDL60="; + }; + }; + enable = true; + autoStart = true; + capSysAdmin = true; + openFirewall = true; + + }; + + + + + + + + + + virtualisation.vmVariant.services.timesyncd.enable = lib.mkForce false; + services.tailscale.enable = true; + + services.resilio = { + enable = true; + enableWebUI = true; + }; + users.users.me.homeMode = "770"; # important for resilio + + virtualisation.waydroid.enable = true; @@ -60,6 +96,16 @@ + ################# make firefox default browser + xdg.mime.defaultApplications = { + "text/html" = "firefox.desktop"; + "x-scheme-handler/http" = "firefox.desktop"; + "x-scheme-handler/https" = "firefox.desktop"; + "x-scheme-handler/about" = "firefox.desktop"; + "x-scheme-handler/unknown" = "firefox.desktop"; + }; + + # disable touch clicks because i always tap while typing @@ -89,6 +135,16 @@ ]; services.udev.packages = [ inputs.waveforms.packages.${system}.adept2-runtime ]; + users.users.rslsync.extraGroups = ["users"]; + + # add myself to plugdev group for waveforms + # and incus-admin to use incus without sudo + users.users.me.extraGroups = [ "incus-admin" "plugdev" "rslsync" ]; + + + nixpkgs.config.permittedInsecurePackages = [ + "python-2.7.18.8" + ]; environment.systemPackages = with pkgs; [ @@ -251,10 +307,14 @@ #networking.useDHCP = lib.mkForce true; networking.firewall.allowPing = true; - networking.firewall.enable = false; + networking.firewall.enable = true; services.samba.openFirewall = true; + networking.firewall.interfaces."tailscale0".allowedTCPPorts = [ + 44444 # resilio sync + ]; + networking.firewall.allowedTCPPorts = [ 5357 # wsdd 8888 # for general usage @@ -485,42 +545,49 @@ # */ + systemd.services.waydroid = { + enable = false; + description = "run waydroid session in background"; + unitConfig = { + Type = "simple"; + }; + serviceConfig = { + Restart = "always"; + RestartSec = "500s"; + ExecStart = "${pkgs.waydroid}/bin/waydroid session start"; + User = "me"; + Group = "users"; + }; + wantedBy = [ "multi-user.target" ]; + }; + #################################### samba ###################################### + /* services.samba-wsdd.enable = true; # make shares visible for windows 10 clients services.samba = { enable = true; securityType = "user"; - extraConfig = '' - security = user - map to guest = bad user - guest account = me - - server role = standalone server - workgroup = WORKGROUP - ''; - shares = { - rpi_schule = { - path = "${workDir}/rpi-schule/"; - "guest ok" = "yes"; - "read only" = "no"; - public = "yes"; - writable = "yes"; - printable = "no"; - comment = "share for rpi in school wlan"; - }; - + settings = { + global = { + "security" = "user"; + "map to guest" = "bad user"; + "guest account" = "me"; + "server role" = "standalone server"; + "workgroup" = "WORKGROUP"; + }; share = { comment = "share for sharing stuff"; path = "${workDir}/share"; public = "yes"; - "guest ok" = "yes"; + "guest ok" = "yes"; "read only" = "no"; writable = "yes"; }; }; }; + */ ######################################### virtualisation ############################### @@ -541,10 +608,6 @@ systemd.services.incus.path = [ pkgs.swtpm ]; #virtualisation.incus.package = inputs.nixpkgs-unstable.legacyPackages.x86_64-linux.incus; - # add myself to plugdev group for waveforms - # and incus-admin to use incus without sudo - users.users.me.extraGroups = [ "incus-admin" "plugdev" ]; - virtualisation.podman.enable = true; diff --git a/hosts/mosatop.nix b/hosts/mosatop.nix new file mode 100644 index 0000000..abd54a6 --- /dev/null +++ b/hosts/mosatop.nix @@ -0,0 +1,62 @@ +{ pkgs, inputs, secretsDir, ...}: +{ + imports = [ + ../users/me/headless.nix + ../common/wsl.nix + + inputs.networkmanager.nixosModules.networkmanager + inputs.home-manager.nixosModules.home-manager + ../common/all.nix + ../common/nixos-headless.nix + ]; + + + # to build rpi images + boot.binfmt.emulatedSystems = [ + "aarch64-linux" + "armv7l-linux" + ]; + + + ######################### networking ##################################### + + networking.hostName = "mosatop"; + networking.firewall.allowPing = true; + networking.firewall.enable = true; + networking.firewall.allowedUDPPorts = [ + 3702 # wsdd + 51820 # wireguard + 24454 # minecraft voice chat + ]; + networking.firewall.allowedTCPPorts = [ + 2222 # sshd + 8888 # general use + 9999 # general use + 25565 # minecraft + ]; + + + networking.networkmanager.enable = true; + +/* + networking.networkmanager.profiles = { + me = { + connection = { + id = "me"; + uuid = "fe45d3bc-21c6-41ff-bc06-c936017c6e02"; + type = "wireguard"; + autoconnect = "true"; + interface-name = "me0"; + }; + wireguard = { + listen-port = "51820"; + private-key = builtins.readFile "${secretsDir}/wg-private-acern"; + }; + ipv4 = { + address1 = "10.1.1.5/24"; + method = "manual"; + }; + } // (import ../common/wg-peers.nix { inherit secretsDir; }) ; + }; + */ +} diff --git a/misc/my-hosts b/misc/my-hosts index 57b4630..5f78b8e 100644 --- a/misc/my-hosts +++ b/misc/my-hosts @@ -6,3 +6,4 @@ ::1 youtube.com ::1 localhost 127.0.0.1 localhost +100.70.54.18 obsidian.c2vi.dev diff --git a/misc/my-hosts-h b/misc/my-hosts-h index 2206e01..3b44d6c 100644 --- a/misc/my-hosts-h +++ b/misc/my-hosts-h @@ -6,3 +6,5 @@ 192.168.1.1 rou 192.168.1.1 router 192.168.1.33 mac +192.168.1.36 mosatop +192.168.1.37 lush diff --git a/mybin/nixre b/mybin/nixre index abd7841..3749ec0 100755 --- a/mybin/nixre +++ b/mybin/nixre @@ -3,6 +3,8 @@ # my nixos rebuild script +set -e + build_from_github(){ export NIXPKGS_ALLOW_UNFREE=1 @@ -38,11 +40,36 @@ build_from_local(){ return $build_exit_code } +build_remote () { + +rsync -r -v $HOME/work/config/* $host:my-nixos-config --exclude=.git --exclude=gitignore + +out_path=$(ssh $host nix build "\$HOME/my-nixos-config#nixosConfigurations.$host.config.system.build.toplevel" --impure --no-link --print-out-paths -v -L "${args_to_pass[@]}") + +if [[ "$out_path" == "" ]] +then + build_exit_code=1 +else + build_exit_code=0 +fi + +echo out_path: $out_path +echo build_exit_code: $build_exit_code + +return $build_exit_code + +} + + do_switch(){ if [[ "$host" == "$(hostname)" ]] then [[ "$boot" == "false" ]] && sudo $out_path/bin/switch-to-configuration switch [[ "$boot" == "true" ]] && sudo $out_path/bin/switch-to-configuration boot + elif [[ "$build_remote" == "true" ]] + then + [[ "$boot" == "false" ]] && ssh $host "sudo nixos-rebuild switch --flake \$HOME/my-nixos-config --impure" + [[ "$boot" == "true" ]] && ssh $host "sudo nixos-rebuild boot --flake \$HOME/my-nixos-config --impure" else nix path-info $out_path -r | xargs sudo nix store sign -k ~/work/here/secrets/nix-private nix copy --no-check-sigs --no-require-sigs --to ssh-ng://$host $out_path @@ -67,11 +94,12 @@ boot=false use_github="" flag="" -while getopts ':gbh:' flag; do +while getopts ':rgbh:' flag; do case "${flag}" in h) host="${OPTARG}";; b) boot=true;; g) use_github=true;; + r) build_remote=true;; *) export args_to_pass=( "${@:OPTIND}" ); break;; # makes it so, that at the first unknown option we start passing the rest of the arguments to the nix build command.... esac done @@ -84,10 +112,19 @@ done #exit +if [[ "$host" == "acern" ]] || [[ "$host" == "mosatop" ]] +then +build_remote=true +fi + + if [[ "$use_github" == "true" ]] then echo rebuild from github build_from_github && do_switch +elif [[ "$build_remote" == "true" ]] +then + build_remote && do_switch else echo "rebuild from local (~/work/config/)" build_from_local && do_switch diff --git a/mybin/ru b/mybin/ru index e489d4a..f84e4c6 100755 --- a/mybin/ru +++ b/mybin/ru @@ -27,6 +27,18 @@ then rclone mount --vfs-cache-mode full -vvvv onedrive-school:projekt-autobatterie ~/work/htl/projekt/wechner/mnt +elif [ "$1" == "mnt-host" ] +then +if [[ "$1" == "-r" ]] +then + host=$3 + sshfs $host:/ ~/mnt +else + host=$2 + sshfs $host: ~/mnt +fi + + elif [ "$1" == "mnt-school" ] then rclone mount --vfs-cache-mode full -vvvv onedrive-school: ~/mnt @@ -41,7 +53,7 @@ wstunnel -L 55555:127.0.0.1:49388 ws://sebastian.dns.army:49389 elif [ "$1" == "speed-test-nixos-iso" ] then -wget -O /tmp/speed-test.iso "https://dl.t2sde.org/binary/2022/t2-22.6-x86-64-minimal-desktop-gcc-glibc.iso" +wget -O /tmp/speed-test.iso "https://channels.nixos.org/nixos-24.11/latest-nixos-gnome-x86_64-linux.iso" rm /tmp/speed-test.iso diff --git a/mybin/waydroid-session-start b/mybin/waydroid-session-start new file mode 100755 index 0000000..17cb434 --- /dev/null +++ b/mybin/waydroid-session-start @@ -0,0 +1 @@ +waydroid session start diff --git a/mybin/waydroid-session-stop b/mybin/waydroid-session-stop new file mode 100755 index 0000000..c40df20 --- /dev/null +++ b/mybin/waydroid-session-stop @@ -0,0 +1 @@ +waydroid session stop diff --git a/programs/bash.nix b/programs/bash.nix index 962e18d..0b9451b 100644 --- a/programs/bash.nix +++ b/programs/bash.nix @@ -1,19 +1,17 @@ -{ persistentDir, confDir, hostname, self, pkgs, config, system, inputs, workDir, ... }: +{ secretsDir, confDir, hostname, self, pkgs, config, system, inputs, workDir, ... }: { programs.bash = { enable = true; enableCompletion = true; - historyFile = "/home/$USER/work/app-data/${hostname}/bash-history"; + historyFile = if hostname == "main" then "/home/$USER/work/app-data/${hostname}/bash-history" else "/home/$USER/here/bash-history"; historyFileSize = 100000; historyControl = [ "ignoredups" ]; historyIgnore = [ "ls" "cd" "exit" - "sd vim /etc/hosts" - "sd vim /etc/host-youtube-block" ]; shellOptions = [ @@ -46,6 +44,7 @@ shellAliases = { ports = "${pkgs.lsof}/bin/lsof -i -P -n"; losetup = "${pkgs.util-linux}/bin/losetup"; + u = "sudo umount ~/mnt"; #log = let #log = pkgs.writeShellApplication { #name = "log"; @@ -89,7 +88,7 @@ export PATH=${self}/mybin:$PATH export TERM="xterm-color" export system=${system} - export NIX_PATH=$NIX_PATH:nixpkgs=${self} + export NIX_PATH=nixpkgs=${self.inputs.nixpkgs.outPath} export NIXPKGS_ALLOW_UNFREE=1 # the commit hash of nixpkgs 23.11 @@ -113,11 +112,33 @@ fi + + function lf () { ${config.programs.lf.package}/bin/lf -last-dir-path /tmp/lf-last-path && cd $(cat /tmp/lf-last-path) } + + + + function rp () { + host=$1 + + if [[ "$host" == "mosatop" ]] + then + xfreerdp /u:"c2vi" /v:mosatop /p:$(cat ${secretsDir}/mosatop-rdp-password) /dynamic-resolution +clipboard +auto-reconnect /wm-class:"Microsoft Windows" + + elif [[ "$host" == "acern" ]] + then + xfreerdp /u:"seb" /v:acern /p:$(cat ${secretsDir}/acern-rdp-password) /dynamic-resolution +clipboard +auto-reconnect /wm-class:"Microsoft Windows" + + fi + } + complete -W "mosatop acern" rp + + + # so that programms i spawn from my shell don't have so high cpu priority [ which renice 2>/dev/null ] && renice -n 9 $$ > /dev/null @@ -178,11 +199,9 @@ # ------------------------------------------------ cb() { local _scs_col="\e[0;32m"; local _wrn_col='\e[1;31m'; local _trn_col='\e[0;33m' - # Check that xclip is installed. - if ! type xclip > /dev/null 2>&1; then - echo -e "$_wrn_col""You must have the 'xclip' program installed.\e[0m" + # Check user is not root (root doesn't have access to user xorg server) - elif [[ "$USER" == "root" ]]; then + if [[ "$USER" == "root" ]]; then echo -e "$_wrn_col""Must be regular user (not root) to copy a file to the clipboard.\e[0m" else # If no tty, data should be available on stdin @@ -198,7 +217,7 @@ echo " echo | cb" else # Copy input to clipboard - echo -n "$input" | xclip -selection c + echo -n "$input" | wl-copy # Truncate text for status if [ ''${#input} -gt 80 ]; then input="$(echo $input | cut -c1-80)$_trn_col...\e[0m"; fi # Print status. @@ -326,7 +345,7 @@ complete -W "start stop restart status daemon-reload" stl # run - complete -W "mnt-wechner sync-school wstunnel hibernate p speed-test-nixos-iso speed-test-upload speed-test-download bat bstat mnt-files-local mnt-lan-local mnt-files-remote mnt-lan-remote suspend rm-tab-cur rm-last-char mnt-school" ru + complete -W "mnt-wechner sync-school wstunnel hibernate p speed-test-nixos-iso speed-test-upload speed-test-download bat bstat mnt-files-local mnt-lan-local mnt-files-remote mnt-lan-remote suspend rm-tab-cur rm-last-char mnt-school mnt-host" ru ''; diff --git a/programs/ssh.nix b/programs/ssh.nix index 56572cd..d639a8a 100644 --- a/programs/ssh.nix +++ b/programs/ssh.nix @@ -6,7 +6,7 @@ "*" = { identityFile = "${secretsDir}/private-key"; }; - pcmc = { + ouranos = { hostname = "195.201.148.94"; user = "root"; }; @@ -51,6 +51,10 @@ acern = { user = "me"; port = 2222; + }; + mosatop = { + user = "me"; + port = 2222; }; hpm = { user = "me"; diff --git a/scripts/start-wsl.bat b/scripts/start-wsl.bat new file mode 100644 index 0000000..c71d0ef --- /dev/null +++ b/scripts/start-wsl.bat @@ -0,0 +1,2 @@ +@echo off +wsl --shell-type login -- /bin/sh -c "source /home/me/.bashrc; while true; sleep 9999999; echo hi; done &" diff --git a/users/me/gui-home.nix b/users/me/gui-home.nix index 199f133..e57afcf 100755 --- a/users/me/gui-home.nix +++ b/users/me/gui-home.nix @@ -33,11 +33,10 @@ home.file = { - ".mysecrets/root-pwd".text = "changemehiiii"; - ".mysecrets/me-pwd".text = "changeme"; - #".mozilla/firefox".source = config.lib.file.mkOutOfStoreSymlink "${persistentDir}/firefox"; ".cache/rofi-3.runcache".source = config.lib.file.mkOutOfStoreSymlink "${persistentDir}/rofi-run-cache"; + + ".local/share/PrismLauncher/".source = config.lib.file.mkOutOfStoreSymlink "${workDir}/app-data/prism-launcher"; }; @@ -126,7 +125,7 @@ (pkgs.writeShellApplication { name = "rpi"; text = let - myPythonRpi = pkgs.writers.writePython3Bin "myPythonRpi" { libraries = [pkgs.python311Packages.dnspython]; } '' + myPythonRpi = pkgs.writers.writePython3Bin "myPythonRpi" { libraries = [pkgs.python3Packages.dnspython]; } '' # flake8: noqa import os import re diff --git a/users/server/headles.nix b/users/server/headless.nix similarity index 100% rename from users/server/headles.nix rename to users/server/headless.nix