summaryrefslogtreecommitdiffstats
path: root/lass/5pkgs
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2017-01-25 23:23:29 +0100
committermakefu <github@syntax-fehler.de>2017-01-25 23:23:29 +0100
commitbf405736962fd20df738f84665e5fc7f8d74e72d (patch)
treeae01054fe88089d6476b3c1b1952066fd6c79092 /lass/5pkgs
parent7e1bd2729e11e5c63749c69093359de0bb3329b2 (diff)
parent89c5b22129d3cb875d16a3171a4e3ab3bee9cb0a (diff)
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'lass/5pkgs')
-rw-r--r--lass/5pkgs/default.nix3
-rw-r--r--lass/5pkgs/init/default.nix143
-rw-r--r--lass/5pkgs/xmonad-lass.nix10
3 files changed, 151 insertions, 5 deletions
diff --git a/lass/5pkgs/default.nix b/lass/5pkgs/default.nix
index 0beda7481..e47e3126a 100644
--- a/lass/5pkgs/default.nix
+++ b/lass/5pkgs/default.nix
@@ -1,4 +1,4 @@
-{ pkgs, ... }:
+{ pkgs, ... }@args:
{
nixpkgs.config.packageOverrides = rec {
@@ -11,6 +11,7 @@
ublock = pkgs.callPackage ./firefoxPlugins/ublock.nix {};
vimperator = pkgs.callPackage ./firefoxPlugins/vimperator.nix {};
};
+ init = pkgs.callPackage ./init/default.nix args;
mk_sql_pair = pkgs.callPackage ./mk_sql_pair/default.nix {};
mpv-poll = pkgs.callPackage ./mpv-poll/default.nix {};
pop = pkgs.callPackage ./pop/default.nix {};
diff --git a/lass/5pkgs/init/default.nix b/lass/5pkgs/init/default.nix
new file mode 100644
index 000000000..b484d2c38
--- /dev/null
+++ b/lass/5pkgs/init/default.nix
@@ -0,0 +1,143 @@
+{ pkgs, lib, pubkey ? "", disk ? "/dev/sda", vgname ? "pool", luksmap ? "luksmap", keyfile ? "/root/keyfile", ... }:
+
+with lib;
+
+pkgs.writeText "init" ''
+ #! /bin/sh
+ # usage: curl xu/~tv/init | sh
+ set -efu
+ # TODO nix-env -f '<nixpkgs>' -iA jq # if not exists (also version)
+ # install at tmp location
+
+
+ case $(cat /proc/cmdline) in
+ *' root=LABEL=NIXOS_ISO '*) :;;
+ *) echo Error: unknown operating system >&2; exit 1;;
+ esac
+
+ keyfile=${keyfile}
+
+ disk=${disk}
+
+ luksdev=${disk}2
+ luksmap=/dev/mapper/${luksmap}
+
+ vgname=${vgname}
+
+ rootdev=/dev/mapper/${vgname}-root
+ homedev=/dev/mapper/${vgname}-home
+ bkudev=/dev/mapper/${vgname}-bku
+
+ #
+ #generate keyfile
+ #
+
+ if ! test -e "$keyfile"; then
+ dd if=/dev/urandom bs=512 count=2048 of=$keyfile
+ fi
+
+ #
+ # partitioning
+ #
+
+ # http://en.wikipedia.org/wiki/GUID_Partition_Table
+ # undo:
+ # dd if=/dev/zero bs=512 count=34 of=/dev/sda
+ # TODO zero last 34 blocks (lsblk -bno SIZE /dev/sda)
+ if ! test "$(blkid -o value -s PTTYPE "$disk")" = gpt; then
+ parted -a optimal "$disk" \
+ mklabel gpt \
+ mkpart no-fs 0 1024KiB \
+ set 1 bios_grub on \
+ mkpart primary 1025KiB 100%
+ fi
+
+ if ! test "$(blkid -o value -s PARTLABEL "$luksdev")" = primary; then
+ echo zonk2
+ exit 23
+ fi
+
+ if ! cryptsetup isLuks "$luksdev"; then
+ # aes xts-plain64
+ cryptsetup luksFormat "$luksdev" "$keyfile" \
+ -h sha512 \
+ --iter-time 5000
+ fi
+
+ if ! test -e "$luksmap"; then
+ cryptsetup luksOpen "$luksdev" "$(basename "$luksmap")" \
+ --key-file "$keyfile"
+ fi
+ # cryptsetup close
+
+ if ! test "$(blkid -o value -s TYPE "$luksmap")" = LVM2_member; then
+ pvcreate "$luksmap"
+ fi
+
+ if ! vgdisplay -s "$vgname"; then vgcreate "$vgname" "$luksmap"; fi
+
+ lvchange -a y /dev/mapper/"$vgname"
+
+ if ! test -e "$rootdev"; then lvcreate -L 100G -n root "$vgname"; fi
+ if ! test -e "$homedev"; then lvcreate -L 100G -n home "$vgname"; fi
+ if ! test -e "$bkudev"; then lvcreate -L 200G -n bku "$vgname"; fi
+
+ # lvchange -a n "$vgname"
+
+
+ #
+ # formatting
+ #
+
+ if ! test "$(blkid -o value -s TYPE "$rootdev")" = btrfs; then
+ mkfs.btrfs "$rootdev"
+ fi
+
+ if ! test "$(blkid -o value -s TYPE "$homedev")" = btrfs; then
+ mkfs.btrfs "$homedev"
+ fi
+
+ if ! test "$(blkid -o value -s TYPE "$bkudev")" = btrfs; then
+ mkfs.btrfs "$bkudev"
+ fi
+
+
+ if ! test "$(lsblk -n -o MOUNTPOINT "$rootdev")" = /mnt; then
+ mount "$rootdev" /mnt
+ fi
+ if ! test "$(lsblk -n -o MOUNTPOINT "$homedev")" = /mnt/home; then
+ mkdir -m 0000 -p /mnt/home
+ mount "$homedev" /mnt/home
+ fi
+ if ! test "$(lsblk -n -o MOUNTPOINT "$bkudev")" = /mnt/bku; then
+ mkdir -m 0000 -p /mnt/bku
+ mount "$bkudev" /mnt/bku
+ fi
+
+ # umount -R /mnt
+
+ #
+ # dependencies for stockholm
+ #
+
+ nix-env -iA nixos.git
+
+ mkdir -p /mnt/var/src
+ touch /mnt/var/src/.populate
+
+ #
+ # print all the infos
+ #
+
+ parted "$disk" print
+ lsblk "$disk"
+
+ key='${pubkey}'
+ if [ "$(cat /root/.ssh/authorized_keys 2>/dev/null)" != "$key" ]; then
+ mkdir -p /root/.ssh
+ echo "$key" > /root/.ssh/authorized_keys
+ fi
+ systemctl start sshd
+ ip route
+ echo READY.
+''
diff --git a/lass/5pkgs/xmonad-lass.nix b/lass/5pkgs/xmonad-lass.nix
index ec3ad82af..cf8eaf058 100644
--- a/lass/5pkgs/xmonad-lass.nix
+++ b/lass/5pkgs/xmonad-lass.nix
@@ -114,10 +114,10 @@ myKeyMap =
[ ("M4-<F11>", spawn "${pkgs.i3lock}/bin/i3lock -i /var/lib/wallpaper/wallpaper -f")
, ("M4-C-p", spawn "${pkgs.scrot}/bin/scrot ~/public_html/scrot.png")
, ("M4-p", spawn "${pkgs.pass}/bin/passmenu --type")
- , ("<XF86AudioRaiseVolume>", spawn "${pkgs.pulseaudioLight.out}/bin/pactl -- set-sink-volume 0 +4%")
- , ("<XF86AudioLowerVolume>", spawn "${pkgs.pulseaudioLight.out}/bin/pactl -- set-sink-volume 0 -4%")
- , ("<XF86AudioMute>", spawn "${pkgs.pulseaudioLight.out}/bin/pactl -- set-sink-mute 0 toggle")
- , ("<XF86AudioMicMute>", spawn "${pkgs.pulseaudioLight.out}/bin/pactl -- set-source-mute 1 toggle")
+ , ("<XF86AudioRaiseVolume>", spawn "${pkgs.pulseaudioLight.out}/bin/pactl -- set-sink-volume @DEFAULT_SINK@ +4%")
+ , ("<XF86AudioLowerVolume>", spawn "${pkgs.pulseaudioLight.out}/bin/pactl -- set-sink-volume @DEFAULT_SINK@ -4%")
+ , ("<XF86MonBrightnessDown>", spawn "${pkgs.xorg.xbacklight}/bin/xbacklight -time 0 -dec 1%")
+ , ("<XF86MonBrightnessUp>", spawn "${pkgs.xorg.xbacklight}/bin/xbacklight -time 0 -inc 1")
, ("<XF86Launch1>", gridselectWorkspace gridConfig W.view)
, ("M4-C-k", spawn "${pkgs.xorg.xkill}/bin/xkill")
@@ -144,6 +144,8 @@ myKeyMap =
, ("M4-C-q", windowPromptBringCopy infixAutoXPConfig)
, ("M4-S-q", return ())
+
+ , ("M4-w", floatNext True >> spawn "${pkgs.copyq}/bin/copyq show")
]
forkFile :: FilePath -> [String] -> Maybe [(String, String)] -> X ()