Skip to content

Instantly share code, notes, and snippets.

@pseud0n
pseud0n / nixos-encrypted-zfs.sh
Last active January 27, 2023 22:05 — forked from dvogeldev/nixos-encrypted-zfs.sh
How I installed Encrypted ZFS root on NixOS
#!/bin/sh
disk=sda
bootpart=1
mainpart=2
# sda1 for boot, sda2 for main, may vary if doing a dual boot
# FIRST STOP THE zfs-zed SERVICE
systemctl stop zfs-zed
data BoundsError = BoundsError { listLength :: Int, attemptedToGet :: Int } deriving Show
getItem :: Int -> Int -> [a] -> Either a BoundsError
getItem traversedLength tryingToGet [] = Right $ BoundsError traversedLength (tryingToGet + traversedLength)
getItem _ 0 (x:_) = Left x
getItem traversedLength tryingToGet (x:xs) = getItem (traversedLength + 1) (tryingToGet - 1) xs
main :: IO ()
main = do
print $ getItem 0 50 [0..10]
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
class Meta(type):
def __getattr__(cls, key):
return globals()[key]
def __setattr__(cls, key, value):
globals()[key] = value
def hasattr_(cls, key, original = hasattr):
if "hasattr" in cls.__dict__.keys(): #No recursion today
return key in globals().keys()