JolHarg Blog
  • JolHarg
  • » JolHarg Blog » Posts tagged with nixos
    Posts tagged with nixos
    2022

    December

    Raspberry Pi Pico (W) on NixOS


    2021

    March

    Ephemeral system with NixOS


    Posts tagged with nixos
    2022

    December

    Raspberry Pi Pico (W) on NixOS


    2021

    March

    Ephemeral system with NixOS


    Raspberry Pi Pico (W) on NixOS

    Permalink | Author: Dan Dart | Published: 2022-12-20 19:16:15 UTC | Tags: nixos pi pico raspberry w


    If you're following my GitHub, you'll know I've got a new testing project for the Raspberry Pi Pico (W).

    Here's the shell.nix file again:

    with import <nixpkgs> {};
    runCommand "pico" {
        shellHook = ''
          export PICO_SDK_FETCH_FROM_GIT=on
          export PICO_EXTRAS_FETCH_FROM_GIT=on
          export BOARD=pico-w
          export PICO_BOARD=pico_w
        '';
        buildInputs = [
          cmake
          gcc
          gcc-arm-embedded-10
          gnumake
          pico-sdk
          picotool
          python311
        ];
    } ""

    Putting this in the root of a directory allows one to compile Pico (W) projects, avoiding polluting the global environment.

    Huzzah!



    Comments

    No comments yet...

    Post a comment:



    Ephemeral system with NixOS

    Permalink | Author: Dan Dart | Published: 2021-03-20 13:01:00 UTC | Tags: delete ephemeral nixos system


    Recently, I discovered the following reddit post and blog posts:

    • Erasing root on every boot
    • Erase your darlings
    • NixOS ❄: tmpfs as root
    • NixOS ❄: tmpfs as home

    I thought I didn't need any kind of persistence tool, because btrfs is awesome. So I decided to give it a go myself.

    In my case, I'm using btrfs so it's very easy to get going with.

    I went through and decided I wanted to keep:

    • /nix (of course, I don't want to have to download everything all the time)
    • /home (for now, I'll have a go at that one later)
    • /var/lib (databases, docker, etc)
    • /etc/ssh (host keys)
    • /etc/NetworkManager (system connections, VPNs etc)

    And I was content with the rest being recreated on boot, especially /tmp, because it vastly speeds up a lot of things!

    Firstly I converted the directories I wanted to keep into subvolumes (in rescue mode or live/other OS):

    mv /dir-to-keep /dir2
    btrfs su c /dir-to-keep
    cp -rpv --reflink=always /dir2/* /dir-to-keep/
    rm -rf /dir2

    --reflink=always makes a CoW copy in btrfs, so this is a much faster way to copy over data.

    This worked for most of my directories, except for /nix, so I had to use --reflink=auto because I had a lot of hard links due to nix-store optimisation, so it'll CoW only that which it can.

    Noteworthy is that to do /nix to avoid commands disappearing involves doing this (optionally from the running system):

    btrfs su c /nix2
    cp -rpv --reflink=auto /nix/* /nix2/ # Many hardlinks may be duplicated!

    and then from a live or other system (because moving things in-use is dangerous and may not actually work):

    mount /dev/XXX /mnt/root
    rm -rf /mnt/root/nix
    mv /mnt/root/nix2 /mnt/root/nix

    Finally I'm able to have / as a tmpfs!

    So I added the following to hardware-configuration.nix:

    {
      fileSystems."/" =
        {
          device = "tmpfs";
          fsType = "tmpfs";
          options = [
            "size=2G"
          ];
        };
    
      fileSystems."/nix" =
        {
          device = "/dev/XXX";
          fsType = "btrfs";
          options = [
            "subvol=/nix"
            "noatime"
          ];
        };
    
      fileSystems."/etc/ssh" =
        {
          device = "/dev/XXX";
          fsType = "btrfs";
          options = [
            "subvol=/etc/ssh"
            "noatime"
          ];
        };
    
      fileSystems."/etc/NetworkManager" =
        {
          device = "/dev/XXX";
          fsType = "btrfs";
          options = [
            "subvol=/etc/NetworkManager"
            "noatime"
          ];
        };
    
      fileSystems."/var/lib" =
        {
          device = "/dev/XXX";
          fsType = "btrfs";
          options = [
            "subvol=/var/lib"
            "noatime"
          ];
        };
    
      fileSystems."/home" =
        {
          device = "/dev/XXX";
          fsType = "btrfs";
          options = [
            "subvol=/home"
            "noatime"
          ];
        };
    }

    and making sure my passwords were immutable and persistent via the clauses in configuration.nix:

    {
      users.mutableUsers = false;
      users.users.root.initialHashedPassword = "$6$8RZ1PPxKU6h$dNHnIWiq.h8s.7SpMW14FzK9bJwg1f6Mt.972/2Fij4zPrhR0X4m3JTNPtGAyeMKZk3I8x/Xro.vJolwVvwd9.";
      users.users.dwd.initialHashedPassword = "$6$EDn9CboEV/$ESAQifZD0wiVkYf1MuyLqs.hP7mvelpoPnSGEI7CmwuUifi090PT6FQqHsdhlZSXSlqrT9EH.mIfUvxPCA5q.1";
    }

    (hey, they're hashed and SHA-512'd, do you want to try to crack them?)

    Triggering a rebuild and a reboot (to actually apply / as tmpfs), and success! Hooray!

    I can now delete everything from the root subvolume that I didn't make into a subvolume.

    tree -x from the root subvolume now looks like:

    $ tree -x
    .
    ├── etc
    │   ├── NetworkManager
    │   └── ssh
    ├── home
    ├── nix
    └── var
        └── lib

    so I can share these with another OS if I so wish.

    I'm currently investigating doing the same to /home, so I'll keep you updated.

    Till next time!



    Comments

    instagram takipci satin al (URL) said on 2021-04-04T09:56:26.92895773Z:

    Good info. Lucky me I came across your site by chance (stumbleupon). I have saved it for later!


    ucuz takipi sat1n al (URL) said on 2021-03-25T21:58:47.004825757Z:

    Howdy would you mind sharing which blog platform you're using? I'm planning to start my own blog soon but I'm having a difficult time making a decision between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I'm looking for something completely unique. P.S My apologies for being off-topic but I had to ask!


    ucuz takipçi sat1n al (URL) said on 2021-03-22T14:14:24.783260217Z:

    Wonderful beat ! I would like to apprentice while you amend your site, how could i subscribe for a blog website? The account aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast provided bright clear idea


    instagram takipi sat1n al (URL) said on 2021-03-22T02:07:31.447217857Z:

    You ought to take part in a contest for one of the greatest sites on the net. I am going to highly recommend this site!


    Ruthie Killeen (URL) said on 2021-03-21T17:42:01.247594849Z:

    I all the time used to study post in news papers but now as I am a user of net thus from now I am using net for posts, thanks to web.


    ucuz takipci satin al (URL) said on 2021-03-21T11:31:46.637530455Z:

    I was wondering if you ever considered changing the layout of your blog? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or 2 images. Maybe you could space it out better?



    Post a comment:



    Tags
    • 2
      • 2025
    • 6
      • 64 bit
    • 9
      • 98
      • 9.4
      • 9.2
      • 9.10
    • a
      • azure
      • avast
      • authuser
      • audio
      • argument
      • apps
      • apple
      • appcache
      • app
      • api
      • anti
      • annoying
      • animation
      • android
      • amazon
      • alpha
      • ajax
      • adwords
      • advertising
      • adsense
      • ads
      • adguard
      • address
      • access
    • b
      • built
      • bsd. competition
      • bsd
      • broadcasting
      • blogs
      • blog
      • bilibili
      • bibud
      • bgp
      • behind
      • baidu
    • c
      • custom
      • css
      • creativecommons
      • cracker
      • core
      • copy
      • cool
      • content
      • connection
      • computer
      • compromise
      • company
      • command line
      • com
      • cnn
      • cloud
      • client
      • chromium
      • chrome
      • chatgpt
      • chaplin
      • changed
      • change
      • cddl
      • cc
      • canva
      • cabal
    • d
      • dzen
      • duckduckgo
      • drm
      • drawing
      • dragonflybsd
      • dragonfly
      • dns
      • dialup
      • dial-up
      • dfp
      • device
      • desktop
      • design
      • delete
      • debunked
      • debian
      • dart
      • dailymotion
    • e
      • everything
      • error
      • ephemeral
      • emulation
      • emulate
      • email
      • emai
      • eggs
      • ebay
      • easter
    • f
      • friends
      • freebsd
      • free software
      • free
      • format
      • floss
      • flash
      • firewall
      • files
      • feed
      • fast
      • fandom
      • facebook
    • g
      • gui
      • gsm
      • gpl
      • google
      • gnu
      • gnome
      • globo
      • github
      • git
      • ghc
    • h
      • html5
      • html
      • htc
      • hiatus
      • hayes
      • haskell
      • hardware
      • hacker
    • i
      • itunes
      • isp
      • ipv6
      • ipod
      • internet connection sharing
      • internet
      • intel
      • independent
      • import
      • illusion
      • i7
    • j
      • jim
      • javascript
    • k
      • kernel
      • kde
    • l
      • live
      • linux
      • linkedin
      • licence
      • library
      • libraries
      • l
    • m
      • myths
      • mysql
      • my
      • motorola
      • modem
      • mobile
      • mit
      • minicom
      • microsoft
      • meta
      • messages
      • media
      • market
      • maintain
      • mail.ru
      • m2msupport
    • n
      • not
      • nostalgia
      • nixos
      • new
      • networking
      • network
      • netflix
      • netbsd
      • naver
      • nat
      • naming
    • o
      • oss
      • os
      • operating system
      • opensuse
      • opennic
      • openbsd
      • open source
      • open
    • p
      • public
      • proxy
      • protocol
      • protected
      • projectchaplin
      • project
      • port
      • play
      • pinterest
      • pico
      • pi
      • php
      • phone
      • pcbsd
      • password
      • packages
    • q
      • quora
    • r
      • rules
      • routing
      • rootkit
      • root
      • relevant
      • release
      • reddit
      • recording
      • raspberry
      • rakuten
    • s
      • system
      • support
      • sun
      • still
      • steam
      • standardisation
      • standard
      • ssh
      • sql
      • spotify
      • sorry
      • somewhere
      • something
      • solaris
      • software
      • social
      • sites
      • sharing
      • share
      • settings
      • server
      • serial
      • seo
      • security
      • search
      • screen
      • sco
      • scale
      • samsung
    • t
      • twitch
      • tunnel
      • trojan
      • to
      • tip
      • times
      • tiktok
      • tetlegram
      • temu
      • tech
    • u
      • usb
      • updates
      • updated
      • update
      • unix
      • ubuntu
    • v
      • vk
      • visual
      • vista
      • virus
      • vimeo
      • videos
      • video
    • w
      • wrong
      • worm
      • without
      • with
      • windows
      • wikipedia
      • widevine
      • whoops
      • went
      • welcome
      • websites
      • website
      • webos
      • webm
      • web
      • weather.com
      • war
      • w
    • x
      • xp
      • xhtml
      • xenon
      • x
    • y
      • youtube
      • yahoo
    • z
      • zoom
      • zfs
      • zemlin
    Tags
    • 2
      • 2025
    • 6
      • 64 bit
    • 9
      • 98
      • 9.4
      • 9.2
      • 9.10
    • a
      • azure
      • avast
      • authuser
      • audio
      • argument
      • apps
      • apple
      • appcache
      • app
      • api
      • anti
      • annoying
      • animation
      • android
      • amazon
      • alpha
      • ajax
      • adwords
      • advertising
      • adsense
      • ads
      • adguard
      • address
      • access
    • b
      • built
      • bsd. competition
      • bsd
      • broadcasting
      • blogs
      • blog
      • bilibili
      • bibud
      • bgp
      • behind
      • baidu
    • c
      • custom
      • css
      • creativecommons
      • cracker
      • core
      • copy
      • cool
      • content
      • connection
      • computer
      • compromise
      • company
      • command line
      • com
      • cnn
      • cloud
      • client
      • chromium
      • chrome
      • chatgpt
      • chaplin
      • changed
      • change
      • cddl
      • cc
      • canva
      • cabal
    • d
      • dzen
      • duckduckgo
      • drm
      • drawing
      • dragonflybsd
      • dragonfly
      • dns
      • dialup
      • dial-up
      • dfp
      • device
      • desktop
      • design
      • delete
      • debunked
      • debian
      • dart
      • dailymotion
    • e
      • everything
      • error
      • ephemeral
      • emulation
      • emulate
      • email
      • emai
      • eggs
      • ebay
      • easter
    • f
      • friends
      • freebsd
      • free software
      • free
      • format
      • floss
      • flash
      • firewall
      • files
      • feed
      • fast
      • fandom
      • facebook
    • g
      • gui
      • gsm
      • gpl
      • google
      • gnu
      • gnome
      • globo
      • github
      • git
      • ghc
    • h
      • html5
      • html
      • htc
      • hiatus
      • hayes
      • haskell
      • hardware
      • hacker
    • i
      • itunes
      • isp
      • ipv6
      • ipod
      • internet connection sharing
      • internet
      • intel
      • independent
      • import
      • illusion
      • i7
    • j
      • jim
      • javascript
    • k
      • kernel
      • kde
    • l
      • live
      • linux
      • linkedin
      • licence
      • library
      • libraries
      • l
    • m
      • myths
      • mysql
      • my
      • motorola
      • modem
      • mobile
      • mit
      • minicom
      • microsoft
      • meta
      • messages
      • media
      • market
      • maintain
      • mail.ru
      • m2msupport
    • n
      • not
      • nostalgia
      • nixos
      • new
      • networking
      • network
      • netflix
      • netbsd
      • naver
      • nat
      • naming
    • o
      • oss
      • os
      • operating system
      • opensuse
      • opennic
      • openbsd
      • open source
      • open
    • p
      • public
      • proxy
      • protocol
      • protected
      • projectchaplin
      • project
      • port
      • play
      • pinterest
      • pico
      • pi
      • php
      • phone
      • pcbsd
      • password
      • packages
    • q
      • quora
    • r
      • rules
      • routing
      • rootkit
      • root
      • relevant
      • release
      • reddit
      • recording
      • raspberry
      • rakuten
    • s
      • system
      • support
      • sun
      • still
      • steam
      • standardisation
      • standard
      • ssh
      • sql
      • spotify
      • sorry
      • somewhere
      • something
      • solaris
      • software
      • social
      • sites
      • sharing
      • share
      • settings
      • server
      • serial
      • seo
      • security
      • search
      • screen
      • sco
      • scale
      • samsung
    • t
      • twitch
      • tunnel
      • trojan
      • to
      • tip
      • times
      • tiktok
      • tetlegram
      • temu
      • tech
    • u
      • usb
      • updates
      • updated
      • update
      • unix
      • ubuntu
    • v
      • vk
      • visual
      • vista
      • virus
      • vimeo
      • videos
      • video
    • w
      • wrong
      • worm
      • without
      • with
      • windows
      • wikipedia
      • widevine
      • whoops
      • went
      • welcome
      • websites
      • website
      • webos
      • webm
      • web
      • weather.com
      • war
      • w
    • x
      • xp
      • xhtml
      • xenon
      • x
    • y
      • youtube
      • yahoo
    • z
      • zoom
      • zfs
      • zemlin
  • Atom Feed