4 | { pname, version, src, depsHash, targetJar, renameJar, }:
5 | { lib, stdenv, callPackage, maven, oraclejdk, buildMaven, }:
6 | let
7 | inherit pname version src;
8 |
9 | mavenDeps = stdenv.mkDerivation {
10 | name = "${pname}-${version}-deps";
11 | inherit src;
12 |
13 | nativeBuildInputs = [ oraclejdk maven ];
14 | buildPhase = ''
15 | mvn package \
16 | -Dmaven.test.skip=true \
17 | -Dmaven.repo.local=$out \
18 | -Dmaven.wagon.rto=5000
19 | '';
20 |
21 | # keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
22 | installPhase = ''
23 | find $out -type f \
24 | -name \*.lastUpdated -or \
25 | -name resolver-status.properties -or \
26 | -name _remote.repositories \
27 | -delete
28 | '';
29 |
30 | outputHashAlgo = "sha256";
31 | outputHashMode = "recursive";
32 | outputHash = depsHash;
33 |
34 | doCheck = false;
35 | };
36 | in stdenv.mkDerivation {
37 | inherit pname version src;
38 |
39 | buildInputs = [ oraclejdk maven ];
40 | buildPhase = ''
41 | runHook preBuild
42 |
43 | mvn package --offline \
44 | -Dmaven.test.skip=true \
45 | -Dmaven.repo.local=${mavenDeps.outPath}
46 |
47 | runHook postBuild
48 | '';
49 |
50 | installPhase = ''
51 | runHook preInstall
52 | install -Dm644 target/${targetJar} $out/${renameJar}
53 | runHook postInstall
54 | '';
55 | }
56 |
--------------------------------------------------------------------------------
/packages/ja-netfilter/default.nix:
--------------------------------------------------------------------------------
1 | { lib, writeTextDir, callPackage, symlinkJoin, programName ? null
2 | , enabledPlugins ? null, pluginConfigs ? null, }:
3 | let
4 | packages = callPackage ./packages.nix { };
5 | ja-netfilter = callPackage packages.ja-netfilter { };
6 | callPlugin = name: callPackage packages."plugin-${name}" { };
7 | pluginPackages =
8 | lib.optionals (enabledPlugins != null) (map callPlugin enabledPlugins);
9 | configFiles = lib.optionals (pluginConfigs != null) (lib.mapAttrsToList
10 | (name: value: writeTextDir "share/ja-netfilter/config/${name}.conf" value)
11 | pluginConfigs);
12 | in symlinkJoin {
13 | name = if programName == null then
14 | "ja-netfilter"
15 | else
16 | "ja-netfilter-${programName}";
17 | paths = [ ja-netfilter ] ++ pluginPackages ++ configFiles;
18 | postBuild = lib.optionalString (programName != null) ''
19 | mv $out/share/ja-netfilter/plugins $out/share/ja-netfilter/plugins-${programName}
20 | mv $out/share/ja-netfilter/config $out/share/ja-netfilter/config-${programName}
21 | '';
22 | }
23 |
--------------------------------------------------------------------------------
/packages/ja-netfilter/packages.nix:
--------------------------------------------------------------------------------
1 | { fetchgit, }:
2 | let
3 | repoOwner = "ja-netfilter";
4 | baseName = "ja-netfilter";
5 |
6 | packageBase = import ./base.nix;
7 | pluginBase = { name, version, srcHash, depsHash, }:
8 | packageBase {
9 | pname = "${baseName}-plugin-${name}";
10 | src = fetchgit {
11 | url = "https://gitee.com/${repoOwner}/plugin-${name}.git";
12 | rev = version;
13 | sha256 = srcHash;
14 | };
15 | # maven outputs the jar name with an extra `v` in the version segment
16 | targetJar = "${name}-v${version}-jar-with-dependencies.jar";
17 | renameJar = "share/${baseName}/plugins/${name}.jar";
18 | inherit version depsHash;
19 | };
20 | in {
21 | ja-netfilter = packageBase rec {
22 | pname = baseName;
23 | version = "2022.2.0";
24 | src = fetchgit {
25 | url = "https://gitee.com/${repoOwner}/ja-netfilter.git";
26 | rev = version;
27 | sha256 = "sha256-jlRJ2r9EnbaqG7tGhJduFCchORdraZL3aTBa1btgMIU=";
28 | };
29 | depsHash = "sha256-B8kZKC1FilK/wWNzlrQgDVj+T0EhScK2o2lAtFK8FqY=";
30 | targetJar = "ja-netfilter-jar-with-dependencies.jar";
31 | renameJar = "share/${baseName}/ja-netfilter.jar";
32 | };
33 | plugin-dns = pluginBase {
34 | name = "dns";
35 | version = "v1.1.0";
36 | srcHash = "sha256-JSBGjQY7KmO7pcrATY5Ql9eg+hQUHqy9869uINLz+Fo=";
37 | depsHash = "sha256-B8kZKC1FilK/wWNzlrQgDVj+T0EhScK2o2lAtFK8FqY=";
38 | };
39 | plugin-url = pluginBase {
40 | name = "url";
41 | version = "v1.1.0";
42 | srcHash = "sha256-7YiiPDjQr6vN933svHwz1yK3PdWTsY2SeJsw+PBv+zY=";
43 | depsHash = "sha256-B8kZKC1FilK/wWNzlrQgDVj+T0EhScK2o2lAtFK8FqY=";
44 | };
45 | plugin-hideme = pluginBase {
46 | name = "hideme";
47 | version = "v1.1.0";
48 | srcHash = "sha256-tGAesHIGmdlp2PCTfX5zrikqjD9ZiQ+0tLsJFGiWwPQ=";
49 | depsHash = "sha256-B8kZKC1FilK/wWNzlrQgDVj+T0EhScK2o2lAtFK8FqY=";
50 | };
51 | plugin-dump = pluginBase {
52 | name = "dump";
53 | version = "v1.0.1";
54 | srcHash = "";
55 | depsHash = "";
56 | };
57 | plugin-native = pluginBase {
58 | name = "native";
59 | version = "v1.0.0";
60 | srcHash = "";
61 | depsHash = "";
62 | };
63 | plugin-power = pluginBase {
64 | name = "power";
65 | version = "v1.1.0";
66 | srcHash = "sha256-sTjHvpQYF6soRIDhPspCdLYqLfZwPCjERq1EhIvX9z0=";
67 | depsHash = "sha256-S5SnS27x+vTwHd8Z6J8dO/wgThQClkgQv1WPJkFiyK8=";
68 | };
69 | }
70 |
--------------------------------------------------------------------------------
/packages/java/default.nix:
--------------------------------------------------------------------------------
1 | { lib, pkgs, fetchurl, graalvmCEPackages
2 | , systems ? [ "aarch64-darwin" "aarch64-linux" "x86_64-darwin" "x86_64-linux" ]
3 | }:
4 | let
5 | temurinSources = lib.importJSON ./temurin-sources.json;
6 | graalvmCeSources = lib.importJSON ./graalvm-ce-sources.json;
7 |
8 | mkJava = opts:
9 | pkgs.callPackage (import
10 | "${pkgs.path}/pkgs/development/compilers/temurin-bin/jdk-linux-base.nix"
11 | opts) { };
12 |
13 | mkBorkedGraalVmCe = { url, sha256, version, javaVersion }:
14 | (graalvmCEPackages.buildGraalvm {
15 | inherit version;
16 | javaVersion = toString javaVersion;
17 | src = fetchurl { inherit url sha256; };
18 | meta.platforms = systems;
19 | }).overrideAttrs (self: super: {
20 | doInstallCheck = false;
21 | # Make sure that `native-image` exists so that `wrapProgram`
22 | # has something to do.
23 | preInstall = ''
24 | touch $out/bin/native-image
25 | chmod +x $out/bin/native-image
26 | '' + (super.preInstall or "");
27 | # Remove the `native-image` wrapper and the original empty file.
28 | postFixup = (super.postFixup or "") + ''
29 | rm $out/bin/native-image*
30 | '';
31 | });
32 |
33 | graalvmPlatform = let
34 | os = if pkgs.hostPlatform.isDarwin then
35 | "darwin"
36 | else if pkgs.hostPlatform.isLinux then
37 | "linux"
38 | else
39 | abort "GraalVM is not available for your OS";
40 | arch = if pkgs.hostPlatform.isAarch64 then
41 | "aarch64"
42 | else if pkgs.hostPlatform.is64bit then
43 | "amd64"
44 | else
45 | abort "GraalVM does not support your CPU architecture";
46 | in "${os}-${arch}";
47 |
48 | in lib.makeExtensible (self: {
49 | temurin20-jre-bin = mkJava { sourcePerArch = temurinSources.openjdk20; };
50 | graalvm8-ce = mkBorkedGraalVmCe graalvmCeSources.java8.${graalvmPlatform};
51 | graalvm8-ce-jre = "${self.graalvm8-ce}/jre";
52 | })
53 |
--------------------------------------------------------------------------------
/packages/java/graalvm-ce-sources.json:
--------------------------------------------------------------------------------
1 | {
2 | "java8": {
3 | "linux-amd64": {
4 | "javaVersion": 8,
5 | "version": "21.3.1",
6 | "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.3.1/graalvm-ce-java8-linux-amd64-21.3.1.tar.gz",
7 | "sha256": "sha256-uey9VC3h7Qo9pGpinyJmqIIDJpj1/LxU2JI3K5GJsO0="
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/packages/java/temurin-sources.json:
--------------------------------------------------------------------------------
1 | {
2 | "openjdk20": {
3 | "packageType": "jre",
4 | "vmType": "hotspot",
5 | "x86_64": {
6 | "build": "9",
7 | "sha256": "e3592e86290c192804d9c6b5035d42cc32cf04141d1c0b9d1ecb67739826c8c5",
8 | "url": "https://github.com/adoptium/temurin20-binaries/releases/download/jdk-20.0.2%2B9/OpenJDK20U-jre_x64_linux_hotspot_20.0.2_9.tar.gz",
9 | "version": "20.0.2"
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/json2nix.nix:
--------------------------------------------------------------------------------
1 | # This is a wrapper for `../scripts/json2nix.sh`.
2 | { pkgs, lib, nix, nixfmt-classic, ... }:
3 | pkgs.patchShellScript ../scripts/json2nix.sh rec {
4 | name = "json2nix";
5 | destination = "/bin/${name}";
6 | runtimeInputs = [ nix nixfmt-classic ];
7 | }
8 |
--------------------------------------------------------------------------------
/packages/lib/default.nix:
--------------------------------------------------------------------------------
1 | # FIXME export this somewhere
2 | { callPackage }: { # #
3 | wrapperTools = callPackage ./wrapper-tools.nix { };
4 | }
5 |
--------------------------------------------------------------------------------
/packages/lib/wrapper-tools.nix:
--------------------------------------------------------------------------------
1 | { makeSetupHook, writeScript, writeText, runtimeShell }:
2 | let
3 | hookScript = writeScript "wrapper-tools-setup-hook.in" ''
4 | #!@shell@
5 |
6 | customWrapper() {
7 | local prog="$1"
8 | local wrapper="$2"
9 | local hidden
10 |
11 | assertExecutable "$prog"
12 |
13 | hidden="$(dirname "$prog")/.$(basename "$prog")-wrapped"
14 | while [ -e "$hidden" ]; do
15 | hidden+='_'
16 | done
17 | mv "$prog" "$hidden"
18 |
19 | cp "$wrapper" "$prog"
20 | chmod +x "$prog"
21 | patchShebangs "$prog"
22 | substituteInPlace "$prog" \
23 | --subst-var-by 'shell' '@shell@' \
24 | --subst-var-by 'helpers' '@helpers@' \
25 | --subst-var-by 'program' "$hidden"
26 | }
27 | '';
28 | helperScript = writeText "wrapper-tools-helpers" ''
29 | # shellcheck shell=bash
30 |
31 | # This script is not intended to be run standalone.
32 | # Use the `source` command in your custom wrapper
33 | # to gain access to these functions.
34 |
35 | trimPath() {
36 | local var="$1"
37 | local sep="$2"
38 | eval "$var=\"\''${$var%$sep}\""
39 | eval "$var=\"\''${$var#$sep}\""
40 | }
41 |
42 | prefixPath() {
43 | local var="$1"
44 | local sep="$2"
45 | local value="$3"
46 | eval "$var='$value$sep'\"\$$var\""
47 | trimPath "$var" "$sep"
48 | }
49 |
50 | suffixPath() {
51 | local var="$1"
52 | local sep="$2"
53 | local value="$3"
54 | eval "$var+='$sep$value'"
55 | trimPath "$var" "$sep"
56 | }
57 | '';
58 | in makeSetupHook {
59 | name = "custom-wrapper-hook";
60 | substitutions = {
61 | shell = runtimeShell;
62 | helpers = helperScript;
63 | };
64 | passthru.helpers = helperScript;
65 | } hookScript
66 |
--------------------------------------------------------------------------------
/packages/nerdfonts.nix:
--------------------------------------------------------------------------------
1 | { stdenvNoCC, fetchzip }:
2 | stdenvNoCC.mkDerivation (self: {
3 | pname = "nerdfonts-symbols";
4 | version = "3.0.2";
5 | src = fetchzip {
6 | url =
7 | "https://github.com/ryanoasis/nerd-fonts/releases/download/v${self.version}/NerdFontsSymbolsOnly.tar.xz";
8 | sha256 = "sha256-clfxFE1MvBUKn3NR/3WxW08R/4HZy0qZZi+S4Pt6WvI=";
9 | stripRoot = false;
10 | };
11 | phases = [ "unpackPhase" "installPhase" ];
12 | installPhase = ''
13 | runHook preInstall
14 | mkdir -p $out/share/fonts/truetype
15 | cp ./SymbolsNerdFont{,Mono}-Regular.ttf $out/share/fonts/truetype
16 | runHook postInstall
17 | '';
18 | })
19 |
--------------------------------------------------------------------------------
/packages/overlays.nix:
--------------------------------------------------------------------------------
1 | lib: {
2 | # INDIVIDUAL PACKAGES #
3 |
4 | amdctl = pkgs: _: { # #
5 | amdctl = pkgs.callPackage ./amdctl.nix { };
6 | };
7 |
8 | ja-netfilter = pkgs: _: {
9 | ja-netfilter = pkgs.callPackage ./ja-netfilter { inherit lib; };
10 | };
11 |
12 | prtsc = pkgs: _: { # #
13 | prtsc = pkgs.callPackage ./prtsc { inherit lib; };
14 | };
15 |
16 | ttf-ms-win11 = pkgs: _: {
17 | ttf-ms-win11 = pkgs.callPackage ./ttf-ms-win11 { inherit lib; };
18 | };
19 |
20 | fork-awesome = pkgs: _: {
21 | fork-awesome = pkgs.callPackage ./fork-awesome.nix { inherit lib; };
22 | };
23 |
24 | idlehack = pkgs: _: {
25 | idlehack = pkgs.callPackage ./idlehack.nix { inherit lib; };
26 | };
27 |
28 | proton-ge-custom = pkgs: _: {
29 | proton-ge-custom = pkgs.callPackage ./proton-ge-custom.nix { inherit lib; };
30 | };
31 |
32 | nerdfonts-symbols = pkgs: _: {
33 | nerdfonts-symbols = pkgs.callPackage ./nerdfonts-symbols { inherit lib; };
34 | };
35 |
36 | java = pkgs: _: {
37 | inherit (pkgs.callPackage ./java { inherit lib; })
38 | temurin20-jre-bin graalvm8-ce graalvm8-ce-jre;
39 | };
40 |
41 | wavefox = pkgs: _: {
42 | wavefox = pkgs.callPackage ./wavefox.nix { inherit lib; };
43 | };
44 |
45 | # PACKAGE SETS #
46 |
47 | zsh-plugins = pkgs: _: {
48 | zsh-plugins = pkgs.callPackages ./zsh-plugins.nix { inherit lib; };
49 | };
50 |
51 | firefox-extensions = pkgs: _: {
52 | firefox-extensions =
53 | pkgs.callPackages ./firefox-extensions.nix { inherit lib; };
54 | };
55 |
56 | # SCOPED PACKAGES
57 |
58 | platformio-python = _: pkgs0: {
59 | python3Packages = pkgs0.python3Packages.overrideScope
60 | (ps: _: { platformio = ps.callPackage ./platformio-python.nix { }; });
61 | };
62 |
63 | # SCRIPTS #
64 |
65 | json2nix = pkgs: _: {
66 | json2nix = pkgs.callPackage ./json2nix.nix { inherit lib; };
67 | };
68 | }
69 |
--------------------------------------------------------------------------------
/packages/proton-ge-custom.nix:
--------------------------------------------------------------------------------
1 | # building from source is way too hard
2 | { stdenvNoCC, fetchzip, }:
3 | stdenvNoCC.mkDerivation (self: {
4 | name = "proton-ge-custom";
5 | version = "GE-Proton7-49";
6 | src = fetchzip {
7 | url =
8 | "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/${self.version}/${self.version}.tar.gz";
9 | sha256 = "1wwxh0yk78wprfi1h9n7jf072699vj631dl928n10d61p3r90x82";
10 | };
11 | preferLocalBuild = true;
12 | installPhase = ''
13 | mkdir -p $out/${self.version}
14 | cp -r * $out/${self.version}
15 | '';
16 | })
17 |
--------------------------------------------------------------------------------
/packages/prtsc/default.nix:
--------------------------------------------------------------------------------
1 | { lib, stdenv, makeBinaryWrapper, coreutils, perl, wl-clipboard, slurp, grim, ... }:
2 | stdenv.mkDerivation {
3 | pname = "prtsc";
4 | version = "0.0.1";
5 |
6 | strictDeps = true;
7 |
8 | src = ./.;
9 |
10 | nativeBuildInputs = [ makeBinaryWrapper ];
11 |
12 | installPhase = ''
13 | runHook preInstall
14 |
15 | install -Dm755 ./prtsc.pl $out/bin/prtsc.pl
16 |
17 | runHook postInstall
18 | '';
19 |
20 | postInstall = ''
21 | makeWrapper ${lib.getExe perl} $out/bin/prtsc \
22 | --add-flags "$out/bin/prtsc.pl" \
23 | --set PATH \
24 | "${lib.makeBinPath [ coreutils wl-clipboard slurp grim ]}"
25 | '';
26 |
27 | meta = {
28 | description = "Simple screenshot utility for Wayland";
29 | license = lib.licenses.mit;
30 | platforms = lib.platforms.linux;
31 | maintainers = with lib.maintainers; [ spikespaz ];
32 | };
33 | }
34 |
--------------------------------------------------------------------------------
/packages/wavefox.nix:
--------------------------------------------------------------------------------
1 | { lib, stdenv, fetchFromGitHub }:
2 | stdenv.mkDerivation (self: {
3 | pname = "wavefox-userchrome";
4 | version = "1.8.138-unstable";
5 | src = fetchFromGitHub {
6 | owner = "QNetITQ";
7 | repo = "WaveFox";
8 | # Using this to respect `browser.tabs.tabMinWidth`.
9 | rev = "b8edea63e6543267ee498ec976020f991199eca6";
10 | hash = "sha256-wANcp1ZlZJDoFYwpfp/R63VdRvmhaBL+TgoReSuC11U=";
11 | };
12 | installPhase = ''
13 | mkdir $out
14 | cp -r $src/chrome -T $out
15 | cp -r $src/{README.md,LICENSE} -t $out
16 | '';
17 | })
18 |
--------------------------------------------------------------------------------
/packages/zsh-plugins.nix:
--------------------------------------------------------------------------------
1 | # 1. If a plugin name starts with `zsh-`, leave it alone.
2 | # 2. If a plugin name ends with `-zsh`, remove it and prepend `zsh-`.
3 | # 3. If a plugin name does not contain `zsh`, prefix with `zsh-`.
4 | # 4. In all cases, leave `pname` so that it
5 | # matches the original name of the plugin.
6 | { lib, fetchFromGitHub }:
7 | let
8 | mkZshPlugin = { pname, version, meta ? { }, src }:
9 | src.overrideAttrs (self: super: {
10 | inherit pname version;
11 | name = "${pname}-${version}";
12 | meta = super.meta
13 | // (lib.optionalAttrs (src ? meta && src.meta ? homepage) {
14 | homepage = src.meta.homepage;
15 | }) // meta;
16 | });
17 | in lib.recurseIntoAttrs {
18 | zsh-autosuggestions = mkZshPlugin rec {
19 | pname = "zsh-autosuggestions";
20 | version = "v0.7.0";
21 | src = fetchFromGitHub {
22 | owner = "zsh-users";
23 | repo = pname;
24 | rev = version;
25 | hash = "sha256-KLUYpUu4DHRumQZ3w59m9aTW6TBKMCXl2UcKi4uMd7w=";
26 | };
27 | meta.license = lib.licenses.mit;
28 | };
29 | zsh-autocomplete = mkZshPlugin rec {
30 | pname = "zsh-autocomplete";
31 | version = "23.07.13";
32 | src = fetchFromGitHub {
33 | owner = "marlonrichert";
34 | repo = pname;
35 | rev = version;
36 | hash = "sha256-0NW0TI//qFpUA2Hdx6NaYdQIIUpRSd0Y4NhwBbdssCs=";
37 | };
38 | meta.license = lib.licenses.mit;
39 | };
40 | zsh-edit = mkZshPlugin rec {
41 | pname = "zsh-edit";
42 | version = "unstable-2023-05-13";
43 | src = fetchFromGitHub {
44 | owner = "marlonrichert";
45 | repo = pname;
46 | rev = "9eb286982f96f03371488e910e42afb23802bdfd";
47 | hash = "sha256-LVHkH7fi8BQxLSeV+osdZzar1PQ0/hdb4yZ4oppGBoc=";
48 | };
49 | meta.license = lib.licenses.mit;
50 | };
51 | zsh-autopair = mkZshPlugin rec {
52 | pname = "zsh-autopair";
53 | version = "unstable-2022-10-03";
54 | src = fetchFromGitHub {
55 | owner = "hlissner";
56 | repo = pname;
57 | rev = "396c38a7468458ba29011f2ad4112e4fd35f78e6";
58 | hash = "sha256-PXHxPxFeoYXYMOC29YQKDdMnqTO0toyA7eJTSCV6PGE=";
59 | };
60 | meta.license = lib.licenses.mit;
61 | };
62 | zsh-auto-notify = mkZshPlugin rec {
63 | pname = "zsh-auto-notify";
64 | version = "unstable-2023-06-02";
65 | src = fetchFromGitHub {
66 | owner = "MichaelAquilina";
67 | repo = pname;
68 | rev = "22b2c61ed18514b4002acc626d7f19aa7cb2e34c";
69 | hash = "sha256-x+6UPghRB64nxuhJcBaPQ1kPhsDx3HJv0TLJT5rjZpA=";
70 | };
71 | meta.license = lib.licenses.gpl3;
72 | };
73 | zsh-window-title = mkZshPlugin rec {
74 | pname = "zsh-window-title";
75 | version = "v1.0.2";
76 | src = fetchFromGitHub {
77 | owner = "olets";
78 | repo = pname;
79 | rev = version;
80 | hash = "sha256-efLpDY+cIe2KhRFpTcm85mYUFlTa2ECTIFhP7hjuf+8=";
81 | };
82 | # Actually some cobbled-together license with most parts from:
83 | meta.license = lib.licenses.cc-by-nc-sa-40;
84 | };
85 | zsh-fast-syntax-highlighting = mkZshPlugin rec {
86 | pname = "fast-syntax-highlighting";
87 | version = "unstable-2023-07-05";
88 | src = fetchFromGitHub {
89 | owner = "zdharma-continuum";
90 | repo = pname;
91 | rev = "cf318e06a9b7c9f2219d78f41b46fa6e06011fd9";
92 | hash = "sha256-RVX9ZSzjBW3LpFs2W86lKI6vtcvDWP6EPxzeTcRZua4=";
93 | };
94 | meta.license = lib.licenses.bsd3;
95 | };
96 | }
97 |
--------------------------------------------------------------------------------
/scripts/airplane-mode.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env bash
2 |
3 | set -x
4 |
5 | if [[ $UID -ne 0 ]]; then
6 | sudo "$0" "$@"
7 | exit $?
8 | fi
9 |
10 | if [[ "$1" = toggle ]]; then
11 | if [[ ! -f /var/lib/airplane-mode.state ]]; then
12 | echo 0 > /var/lib/airplane-mode.state
13 | state=0
14 | else
15 | state=$(cat /var/lib/airplane-mode.state)
16 | "$0" $(($state == 1 ? 0 : 1))
17 | fi
18 | elif [[ "$1" -eq 1 ]]; then
19 | systemctl stop iwd.service
20 | systemctl stop bluetooth.service
21 | rfkill block all
22 | echo 1 > /var/lib/airplane-mode.state
23 | elif [[ "$1" -eq 0 ]]; then
24 | rfkill unblock all
25 | systemctl restart iwd.service
26 | systemctl restart bluetooth.service
27 | echo 0 > /var/lib/airplane-mode.state
28 | else
29 | echo 'missing arg: 0 for off, 1 for on, or toggle'
30 | fi
31 |
--------------------------------------------------------------------------------
/scripts/cleanup.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env bash
2 | set -eu
3 |
4 | confirm=1
5 | target='/mnt'
6 | pool='intrepid'
7 | unmount=0
8 | disable_cache=0
9 |
10 | help_message="$(
11 | cat <<- EOF
12 | Synopsis:
13 | Use this script after partitioning to recursively unmount the target,
14 | invalidate zpool cache, and export the pool to ensure that the pool
15 | can be imported without forcing after a reboot.
16 |
17 | Usage:
18 | $(basename "$0") [-y][-h][-t ][-p ][-u][-c]
19 |
20 | Options:
21 | -y | --no-confirm
22 | Skip confirmation and performs changes immediately.
23 | -h | --help
24 | Display this help message.
25 | -t | --target
26 | Specify an alternate path to the root of a filesystem,
27 | for example '/mnt' or '/target'.
28 | -p