From 8988398bffa4c317614a7a902b393564d9ec2378 Mon Sep 17 00:00:00 2001 From: Nikolaos Karaolidis Date: Wed, 31 Jul 2024 09:23:46 +0100 Subject: [PATCH] Add docker Signed-off-by: Nikolaos Karaolidis --- flake.lock | 48 +++++++++---------- flake.nix | 14 +++--- .../common/system/configs/docker/default.nix | 24 ++++++++++ .../user/configs/console/docker/default.nix | 35 ++++++++++++++ hosts/eirene/default.nix | 1 + hosts/eirene/nick.nix | 1 + submodules/home-manager | 1 + submodules/impermanence | 1 + submodules/nixpkgs | 1 + update-submodules.sh | 36 ++++++++++++++ 10 files changed, 131 insertions(+), 31 deletions(-) create mode 100644 hosts/common/system/configs/docker/default.nix create mode 100644 hosts/common/user/configs/console/docker/default.nix create mode 160000 submodules/home-manager create mode 160000 submodules/impermanence create mode 160000 submodules/nixpkgs create mode 100755 update-submodules.sh diff --git a/flake.lock b/flake.lock index b6e2e3c..6e254e7 100644 --- a/flake.lock +++ b/flake.lock @@ -28,11 +28,11 @@ ] }, "locked": { - "lastModified": 1721871128, - "narHash": "sha256-NyWVCnSeePnJHGJxZ0l3zdGQGrVjUcx2IJbV8KIsPf0=", + "lastModified": 1722217815, + "narHash": "sha256-8r5AJ3n8WEDw3rsZLALSuFQ5kJyWOcssNZvPxYLr2yc=", "owner": "nix-community", "repo": "disko", - "rev": "55e874b9c14764cb791e5740f0e92202e41393fc", + "rev": "1e6f8a7b4634fc051cc9361959bf414fcf17e094", "type": "github" }, "original": { @@ -64,11 +64,11 @@ ] }, "locked": { - "lastModified": 1721900142, - "narHash": "sha256-iHIWZxwDfoqpNKxvjSzqzXNIPxI/5KgPmhtNrY2Z+40=", + "lastModified": 1722408750, + "narHash": "sha256-1nKAicPoQVrCcatj84LnAagtCeriztszBlmB2rllnT8=", "owner": "karaolidis", "repo": "home-manager", - "rev": "0828ae6830ae112ce36c8338e3223a751cefa05d", + "rev": "bd83e8a0c3b6af03eb9d9a22251c9e2145d2974c", "type": "github" }, "original": { @@ -80,11 +80,11 @@ }, "impermanence": { "locked": { - "lastModified": 1720000448, - "narHash": "sha256-43dq726JTKmjbvTaOJw35EnsoEnHWuFkQmY8wfXlefg=", + "lastModified": 1722269200, + "narHash": "sha256-Y2xSwoOw15rMVx9hWt05qHzwVOfhVN4WFnhk6sb6Bmo=", "owner": "karaolidis", "repo": "impermanence", - "rev": "48cb5ae525717ed5397607a2bf81c3fdda310a8f", + "rev": "702783a1c47e10c781b9e028b69d4d5999b03ca3", "type": "github" }, "original": { @@ -96,16 +96,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1721928253, - "narHash": "sha256-xuLwutgAyYIwb2mmBJgWHTTfnS0lIDXVzjZUBK6d9hk=", - "owner": "NixOS", + "lastModified": 1722410387, + "narHash": "sha256-QLQoP9P5gFqcsheh7PSdJ58wKjpG+PF+gz/gPIqE79o=", + "owner": "karaolidis", "repo": "nixpkgs", - "rev": "45cbf8d42fff56fcac72bbd31292eb381134be93", + "rev": "3d2d5810a4b7b8ad85b64a5bcfa0548ea04ba5ad", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "master", + "owner": "karaolidis", + "ref": "integration", "repo": "nixpkgs", "type": "github" } @@ -128,11 +128,11 @@ }, "nur": { "locked": { - "lastModified": 1721983543, - "narHash": "sha256-6JmRrY7nIwKYadzJkolIXfGOC5JliYnB1EfGOY/Oh5g=", + "lastModified": 1722409351, + "narHash": "sha256-E4agC4tX1IsRupb5oq3cJiuxkwUjAg5FQMAMdtUYdWo=", "owner": "nix-community", "repo": "NUR", - "rev": "4807c89cf4ece6a96eed72957dcf0d9b8e29b052", + "rev": "efd6fc5b2df7748d3d7f51f70556031618ef4956", "type": "github" }, "original": { @@ -161,11 +161,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1721688883, - "narHash": "sha256-9jsjsRKtJRqNSTXKj9zuDFRf2PGix30nMx9VKyPgD2U=", + "lastModified": 1722114803, + "narHash": "sha256-s6YhI8UHwQvO4cIFLwl1wZ1eS5Cuuw7ld2VzUchdFP0=", "owner": "Mic92", "repo": "sops-nix", - "rev": "aff2f88277dabe695de4773682842c34a0b7fd54", + "rev": "eb34eb588132d653e4c4925d862f1e5a227cc2ab", "type": "github" }, "original": { @@ -182,11 +182,11 @@ ] }, "locked": { - "lastModified": 1722053480, - "narHash": "sha256-DG1jdoSIcRLkQvCs63MSMJmssHTwm4zGOmP3hUtAzSY=", + "lastModified": 1722399017, + "narHash": "sha256-yaOfEwUCOq+Kbk6seLkRzESdCqjStE0UzlqY3/+1XuE=", "owner": "Gerg-L", "repo": "spicetify-nix", - "rev": "e954f700aeaeb1b4df261c68c2391089f655fac8", + "rev": "66d84fe94ab17a86e146f0dbb53f96296dc57f39", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 7eed793..42f18b1 100644 --- a/flake.nix +++ b/flake.nix @@ -2,15 +2,15 @@ inputs = { nixpkgs = { # --- Official - type = "github"; - owner = "NixOS"; - repo = "nixpkgs"; - ref = "master"; - # --- Fork # type = "github"; - # owner = "karaolidis"; + # owner = "NixOS"; # repo = "nixpkgs"; - # ref = "integration"; + # ref = "master"; + # --- Fork + type = "github"; + owner = "karaolidis"; + repo = "nixpkgs"; + ref = "integration"; # --- Local # url = "git+file:./submodules/nixpkgs"; }; diff --git a/hosts/common/system/configs/docker/default.nix b/hosts/common/system/configs/docker/default.nix new file mode 100644 index 0000000..c00120f --- /dev/null +++ b/hosts/common/system/configs/docker/default.nix @@ -0,0 +1,24 @@ +{ pkgs, ... }: +{ + virtualisation.docker = { + enable = true; + enableOnBoot = false; + storageDriver = "btrfs"; + + daemon.settings = { + experimental = true; + ipv6 = true; + fixed-cidr-v6 = "fd00::/80"; + }; + + autoPrune = { + enable = true; + flags = [ "--all" ]; + }; + }; + + environment = { + persistence."/persist".directories = [ "/var/lib/docker" ]; + systemPackages = with pkgs; [ docker-compose ]; + }; +} diff --git a/hosts/common/user/configs/console/docker/default.nix b/hosts/common/user/configs/console/docker/default.nix new file mode 100644 index 0000000..6787a1b --- /dev/null +++ b/hosts/common/user/configs/console/docker/default.nix @@ -0,0 +1,35 @@ +{ + username ? throw "username argument is required", +}: +{ + config, + inputs, + pkgs, + ... +}: +{ + virtualisation.docker.rootless = { + enable = true; + setSocketVariable = true; + enableOnBoot = false; + storageDriver = "btrfs"; + + daemon.settings = { + experimental = true; + ipv6 = true; + fixed-cidr-v6 = "fd00::/80"; + }; + + autoPrune = { + enable = true; + flags = [ "--all" ]; + }; + }; + + # This is not set though home-manager because we need to hide the mount + # otherwise docker complains with the following error: + # dockerd-rootless: failed to start daemon: error initializing graphdriver: prerequisites for driver not satisfied (wrong filesystem?): btrfs + environment.persistence."/persist".users.${username}.directories = [ ".local/share/docker" ]; + + home-manager.users.${username}.home.packages = with pkgs; [ docker-compose ]; +} diff --git a/hosts/eirene/default.nix b/hosts/eirene/default.nix index 994cab7..960c8b0 100644 --- a/hosts/eirene/default.nix +++ b/hosts/eirene/default.nix @@ -5,6 +5,7 @@ ../common/system/configs/brightnessctl ../common/system/configs/btop ../common/system/configs/btrfs + ../common/system/configs/docker ../common/system/configs/fastfetch ../common/system/configs/getty ../common/system/configs/git diff --git a/hosts/eirene/nick.nix b/hosts/eirene/nick.nix index ef85f2a..4f6d28c 100644 --- a/hosts/eirene/nick.nix +++ b/hosts/eirene/nick.nix @@ -11,6 +11,7 @@ in (import ../common/user/configs/console/bluetooth { inherit username; }) (import ../common/user/configs/console/brightnessctl { inherit username; }) (import ../common/user/configs/console/btop { inherit username; }) + (import ../common/user/configs/console/docker { inherit username; }) (import ../common/user/configs/console/ffmpeg { inherit username; }) (import ../common/user/configs/console/git { inherit username; }) (import ../common/user/configs/console/gpg-agent { inherit username; }) diff --git a/submodules/home-manager b/submodules/home-manager new file mode 160000 index 0000000..58cef37 --- /dev/null +++ b/submodules/home-manager @@ -0,0 +1 @@ +Subproject commit 58cef3796271aaeabaed98884d4abaab5d9d162d diff --git a/submodules/impermanence b/submodules/impermanence new file mode 160000 index 0000000..23c1f06 --- /dev/null +++ b/submodules/impermanence @@ -0,0 +1 @@ +Subproject commit 23c1f06316b67cb5dabdfe2973da3785cfe9c34a diff --git a/submodules/nixpkgs b/submodules/nixpkgs new file mode 160000 index 0000000..6952047 --- /dev/null +++ b/submodules/nixpkgs @@ -0,0 +1 @@ +Subproject commit 69520473998b87e92841e510f6368e1d44fe891b diff --git a/update-submodules.sh b/update-submodules.sh new file mode 100755 index 0000000..2399ba5 --- /dev/null +++ b/update-submodules.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +paths=$(git config --file .gitmodules --name-only --get-regexp path | while read -r line; do + path=$(git config --file .gitmodules --get "$line") + url=$(git config --file .gitmodules --get "${line%.*}.url") + if [[ $url == *"karaolidis"* ]]; then + echo "$path" + fi +done) + +for path in $paths; do + echo "Processing submodule: $path" + + cd "$path" + git checkout master + git fetch upstream + git merge upstream/master + + branches=$(git for-each-ref --format='%(refname:short)' refs/heads/ | grep -v '^master$') + for branch in $branches; do + git checkout "$branch" + git rebase master + done + + git checkout master + git push origin --all --force-with-lease + git push origin --tags --force-with-lease + + cd - > /dev/null +done + +echo "All submodules updated successfully."