From f05ee0a6580d1e8393f671403c2e45a827cbed77 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Sun, 12 Mar 2023 17:05:03 +0100 Subject: [PATCH] Started migration towards `flake-parts` Plus shit ton many changes I still had to commit --- flake.lock | 505 +++++++++++++++--------- flake.nix | 52 ++- formatting/default.nix | 11 + hmModules/emacs/default.nix | 2 +- hmModules/firefox/default.nix | 26 +- hmModules/obs-studio/default.nix | 6 + hmModules/shell/default.nix | 56 ++- hmModules/sway/default.nix | 20 +- hosts/default.nix | 132 +++++++ hosts/rock5b/default.nix | 65 ++- hosts/rock5b/hardware-configuration.nix | 2 + hosts/thinkpad/default.nix | 6 +- modules/clamav/default.nix | 10 + modules/kodi/default.nix | 82 ++-- modules/nix/default.nix | 9 - packages/default.nix | 37 ++ shell/default.nix | 19 + utils/default.nix | 172 -------- 18 files changed, 752 insertions(+), 460 deletions(-) create mode 100644 formatting/default.nix create mode 100644 hmModules/obs-studio/default.nix create mode 100644 hosts/default.nix create mode 100644 modules/clamav/default.nix create mode 100644 packages/default.nix create mode 100644 shell/default.nix delete mode 100644 utils/default.nix diff --git a/flake.lock b/flake.lock index 993ba35..0c5c464 100644 --- a/flake.lock +++ b/flake.lock @@ -2,14 +2,15 @@ "nodes": { "agenix": { "inputs": { + "darwin": "darwin", "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1673301561, - "narHash": "sha256-gRUWHbBAtMuPDJQXotoI8u6+3DGBIUZHkyQWpIv7WpM=", + "lastModified": 1676599101, + "narHash": "sha256-CKS6UsOGhoNxGDBt9wyFiWHvtng/+BMAJ4G8ahhe1DE=", "owner": "ryantm", "repo": "agenix", - "rev": "42d371d861a227149dc9a7e03350c9ab8b8ddd68", + "rev": "de657061b13cf329c57a1a9730a5049a971b40b3", "type": "github" }, "original": { @@ -30,11 +31,11 @@ ] }, "locked": { - "lastModified": 1676243541, - "narHash": "sha256-33E6mVXWTEgOSrUNeZXtiPqIdYBMMRjN6T0PYHtNlxw=", + "lastModified": 1677147990, + "narHash": "sha256-VO83jKa/4LdwKmtEhF32+O95jvC1qyVT/scgDcWMsUw=", "owner": "aciceri", "repo": "emacs", - "rev": "0487fc1dd3fd89d4264562e424a07a1a955c9d88", + "rev": "a412295c6d1491d96db9e9f26b932eb806c9f5ea", "type": "github" }, "original": { @@ -51,11 +52,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1670543350, - "narHash": "sha256-JMYwGa2nJPInuVuYbR3XSGUJewTDyeoTDQaALydduko=", + "lastModified": 1676319017, + "narHash": "sha256-gHyshpxoQAc/3sI3eChqmSCvsBimy+Z6EkzwA3aAYgA=", "owner": "nix-community", "repo": "comma", - "rev": "1b07c19774129ebce3af846fb571e1c0b97f24a3", + "rev": "c4001264668c09d44d765e5ccb1182f291cd91a4", "type": "github" }, "original": { @@ -80,6 +81,28 @@ "type": "github" } }, + "darwin": { + "inputs": { + "nixpkgs": [ + "agenix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1673295039, + "narHash": "sha256-AsdYgE8/GPwcelGgrntlijMg4t3hLFJFCRF3tL5WVjA=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "87b9d090ad39b25b2400029c64825fc2a8868943", + "type": "github" + }, + "original": { + "owner": "lnl7", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, "devshell": { "flake": false, "locked": { @@ -112,7 +135,7 @@ "nci", "devshell" ], - "flake-parts": "flake-parts_2", + "flake-parts": "flake-parts_3", "flake-utils-pre-commit": [ "helix", "nci" @@ -167,11 +190,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1676196577, - "narHash": "sha256-nzXTh2VQZDyzIc6ed2+qoRT/FUKkQQAaLEFPy2MKB+A=", + "lastModified": 1677061209, + "narHash": "sha256-WIddVDpQy1d5xA/hKT8z9WwqlcP+RRIAy0cTUtWU7bg=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "25bc792c9fe3ab354e7b51539b4da72ac821dde9", + "rev": "6c39228d24c69ff0d52aedb8c9976bb796ebda2a", "type": "github" }, "original": { @@ -183,11 +206,11 @@ "emacs-src": { "flake": false, "locked": { - "lastModified": 1676224660, - "narHash": "sha256-9CkPx2CHhrwLoDerjMgYnFxeTC3f8IBf8F9rxVldxe0=", + "lastModified": 1677076548, + "narHash": "sha256-yWln8CoiNJpQ8CmjNYaXFj00aJa5mSUIYLdkN+c5KbQ=", "ref": "emacs-29", - "rev": "eb2b0931cf1258b875b031f81a3685eda8ddf5cb", - "revCount": 164478, + "rev": "20c654b6f8fa24ff458e09a1eb101ba198e671f8", + "revCount": 164627, "type": "git", "url": "git://git.savannah.gnu.org/emacs.git" }, @@ -245,38 +268,6 @@ "type": "github" } }, - "flake-compat_3": { - "flake": false, - "locked": { - "lastModified": 1668681692, - "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "009399224d5e398d03b22badca40a37ac85412a1", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, - "flake-compat_4": { - "flake": false, - "locked": { - "lastModified": 1668681692, - "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "009399224d5e398d03b22badca40a37ac85412a1", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -299,6 +290,24 @@ "inputs": { "nixpkgs-lib": "nixpkgs-lib_2" }, + "locked": { + "lastModified": 1678379998, + "narHash": "sha256-TZdfNqftHhDuIFwBcN9MUThx5sQXCTeZk9je5byPKRw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c13d60b89adea3dc20704c045ec4d50dd964d447", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_3": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_3" + }, "locked": { "lastModified": 1668450977, "narHash": "sha256-cfLhMhnvXn6x1vPm+Jow3RiFAUSCw/l1utktCw5rVA4=", @@ -313,6 +322,24 @@ "type": "github" } }, + "flake-parts_4": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_4" + }, + "locked": { + "lastModified": 1678379998, + "narHash": "sha256-TZdfNqftHhDuIFwBcN9MUThx5sQXCTeZk9je5byPKRw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c13d60b89adea3dc20704c045ec4d50dd964d447", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1667395993, @@ -353,8 +380,9 @@ "type": "github" }, "original": { - "id": "flake-utils", - "type": "indirect" + "owner": "numtide", + "repo": "flake-utils", + "type": "github" } }, "flake-utils_4": { @@ -367,9 +395,8 @@ "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" + "id": "flake-utils", + "type": "indirect" } }, "gitignore": { @@ -394,27 +421,6 @@ "type": "github" } }, - "gitignore_2": { - "inputs": { - "nixpkgs": [ - "preCommitHooks", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1660459072, - "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, "helix": { "inputs": { "nci": "nci", @@ -422,11 +428,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1674109388, - "narHash": "sha256-IWV7MmZ2SyO4jtbxwdtso3QT9OBYFzhIwVU6+FyUWdU=", + "lastModified": 1676614658, + "narHash": "sha256-+F2PN8P0vk3gix9oBflTg0G9ESeBlZYaNlMGqy/0K9A=", "owner": "helix-editor", "repo": "helix", - "rev": "efeec1282cd82e255f54b10e94c51f51294598eb", + "rev": "f7edc34e7b0dd4cd0b6582ee32cc43d1c79d7dd7", "type": "github" }, "original": { @@ -443,11 +449,11 @@ "utils": "utils_2" }, "locked": { - "lastModified": 1673343300, - "narHash": "sha256-5Xdj6kpXYMie0MlnGwqK5FaMdsedxvyuakWtyKB3zaQ=", + "lastModified": 1676367705, + "narHash": "sha256-un5UbRat9TwruyImtwUGcKF823rCEp4fQxnsaLFL7CM=", "owner": "nix-community", "repo": "home-manager", - "rev": "176e455371a8371586e8a3ff0d56ee9f3ca2324e", + "rev": "da72e6fc6b7dc0c3f94edbd310aae7cd95c678b5", "type": "github" }, "original": { @@ -459,11 +465,11 @@ "kernel-src": { "flake": false, "locked": { - "lastModified": 1670395302, - "narHash": "sha256-IZdeXSvGips2OPTwXljGPTeR2Kpx70NGQGF0Cd9xa+0=", + "lastModified": 1678442395, + "narHash": "sha256-5q9ZqD+TQmLjKQI/sQetHHOgFRmwoNustb1I0M0f3ok=", "owner": "radxa", "repo": "kernel", - "rev": "ca15bbe36e6c087c96a603db7cc491a01d9a6467", + "rev": "75f35d0549b7588cc561ed63b4246130c38a9c69", "type": "github" }, "original": { @@ -521,13 +527,33 @@ "type": "github" } }, + "nil": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_5", + "rust-overlay": "rust-overlay_2" + }, + "locked": { + "lastModified": 1676390054, + "narHash": "sha256-w0KvrM+9WIEYr0juDh4Vs39ed2IaT0T696fp9pZ7i1I=", + "owner": "oxalica", + "repo": "nil", + "rev": "944d5c335531778a1d7b54a97bf7fb5ec0c3e976", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "nil", + "type": "github" + } + }, "nixosHardware": { "locked": { - "lastModified": 1673440569, - "narHash": "sha256-FQ5o0yI+MH9MgfseeGDsVIIpIqv3BCgq+0NzncuZ9Zo=", + "lastModified": 1675933606, + "narHash": "sha256-y427VhPQHOKkYvkc9MMsL/2R7M11rQxzsRdRLM3htx8=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "88016c96c3c338aa801695cdd9f186820bcfe4d6", + "rev": "44ae00e02e8036a66c08f4decdece7e3bbbefee2", "type": "github" }, "original": { @@ -538,11 +564,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1665732960, - "narHash": "sha256-WBZ+uSHKFyjvd0w4inbm0cNExYTn8lpYFcHEes8tmec=", + "lastModified": 1674641431, + "narHash": "sha256-qfo19qVZBP4qn5M5gXc/h1MDgAtPA5VxJm9s8RUAkVk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4428e23312933a196724da2df7ab78eb5e67a88e", + "rev": "9b97ad7b4330aacda9b2343396eb3df8a853b4fc", "type": "github" }, "original": { @@ -552,6 +578,22 @@ "type": "github" } }, + "nixpkgs-kernel": { + "locked": { + "lastModified": 1656239181, + "narHash": "sha256-wW1xRFBn376yGloXZ4QzBE4hjipMawpV18Lshd9QSPw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f2537a505d45c31fe5d9c27ea9829b6f4c4e6ac5", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "f2537a505d45c31fe5d9c27ea9829b6f4c4e6ac5", + "type": "github" + } + }, "nixpkgs-lib": { "locked": { "dir": "lib", @@ -571,6 +613,24 @@ } }, "nixpkgs-lib_2": { + "locked": { + "dir": "lib", + "lastModified": 1678375444, + "narHash": "sha256-XIgHfGvjFvZQ8hrkfocanCDxMefc/77rXeHvYdzBMc8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "130fa0baaa2b93ec45523fdcde942f6844ee9f6e", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib_3": { "locked": { "dir": "lib", "lastModified": 1665349835, @@ -588,6 +648,24 @@ "type": "github" } }, + "nixpkgs-lib_4": { + "locked": { + "dir": "lib", + "lastModified": 1678375444, + "narHash": "sha256-XIgHfGvjFvZQ8hrkfocanCDxMefc/77rXeHvYdzBMc8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "130fa0baaa2b93ec45523fdcde942f6844ee9f6e", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-stable": { "locked": { "lastModified": 1671271954, @@ -604,60 +682,45 @@ "type": "github" } }, - "nixpkgs-stable_2": { - "locked": { - "lastModified": 1671271954, - "narHash": "sha256-cSvu+bnvN08sOlTBWbBrKaBHQZq8mvk8bgpt0ZJ2Snc=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "d513b448cc2a6da2c8803e3c197c9fc7e67b19e3", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-22.05", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgsStable": { "locked": { - "lastModified": 1672580127, - "narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=", + "lastModified": 1676546582, + "narHash": "sha256-MJ+PXNmUyxnMTFoss7G2lEcUY2cfYZM6RudBAL5aX1k=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0874168639713f547c05947c76124f78441ea46c", + "rev": "2fb7d749c084890192b2cd08ba264e5e4a14df1b", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-22.05", + "ref": "nixos-22.11", "repo": "nixpkgs", "type": "github" } }, "nixpkgsUnstable": { "locked": { - "lastModified": 1673659004, - "narHash": "sha256-fAIbnEt+uBcBfIkPo0KRKg0++2yPyubkNPGNVvqxmtQ=", + "lastModified": 1677342105, + "narHash": "sha256-kv1fpkfCJGb0M+LZaCHFUuIS9kRIwyVgupHu86Y28nc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f907e2ee5ed7a41e5c57f0d88f09a9fcb388ec0f", + "rev": "b1f87ca164a9684404c8829b851c3586c4d9f089", "type": "github" }, "original": { "owner": "NixOS", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_2": { "locked": { - "lastModified": 1676110339, - "narHash": "sha256-kOS/L8OOL2odpCOM11IevfHxcUeE0vnZUQ74EOiwXcs=", + "lastModified": 1673540789, + "narHash": "sha256-xqnxBOK3qctIeUVxecydrEDbEXjsvHCPGPbvsl63M/U=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e5530aba13caff5a4f41713f1265b754dc2abfd8", + "rev": "0f213d0fee84280d8c3a97f7469b988d6fe5fcdf", "type": "github" }, "original": { @@ -701,65 +764,63 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1672262501, - "narHash": "sha256-ZNXqX9lwYo1tOFAqrVtKTLcJ2QMKCr3WuIvpN8emp7I=", - "owner": "NixOS", + "lastModified": 1675309347, + "narHash": "sha256-D3CQ6HRDT2m3XJlrzb5jKq4vNFR5xFTEFKC7iSjlFpM=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "e182da8622a354d44c39b3d7a542dc12cd7baa5f", + "rev": "006c3bd4dd2f5d1d2094047f307cbf9e2b73d9c5", "type": "github" }, "original": { - "owner": "NixOS", - "ref": "nixos-unstable", + "owner": "nixos", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_6": { "locked": { - "lastModified": 1671271357, - "narHash": "sha256-xRJdLbWK4v2SewmSStYrcLa0YGJpleufl44A19XSW8k=", + "lastModified": 1675942811, + "narHash": "sha256-/v4Z9mJmADTpXrdIlAjFa1e+gkpIIROR670UVDQFwIw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "40f79f003b6377bd2f4ed4027dde1f8f922995dd", + "rev": "724bfc0892363087709bd3a5a1666296759154b1", "type": "github" }, "original": { - "owner": "NixOS", + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "nixpkgs_7": { + "locked": { + "lastModified": 1678470307, + "narHash": "sha256-OEeMUr3ueLIXyW/OaFUX5jUdimyQwMg/7e+/Q0gC/QE=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "0c4800d579af4ed98ecc47d464a5e7b0870c4b1f", + "type": "github" + }, + "original": { + "owner": "nixos", "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } }, - "nixpkgs_7": { - "locked": { - "lastModified": 1656239181, - "narHash": "sha256-wW1xRFBn376yGloXZ4QzBE4hjipMawpV18Lshd9QSPw=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "f2537a505d45c31fe5d9c27ea9829b6f4c4e6ac5", - "type": "github" - }, - "original": { - "owner": "nixos", - "repo": "nixpkgs", - "rev": "f2537a505d45c31fe5d9c27ea9829b6f4c4e6ac5", - "type": "github" - } - }, "nom": { "inputs": { - "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_5", + "flake-utils": "flake-utils_4", + "nixpkgs": "nixpkgs_6", "pre-commit-hooks": "pre-commit-hooks" }, "locked": { - "lastModified": 1672353191, - "narHash": "sha256-e9OwOsD2lfJ8WfcIEcGU6tY9LWB2VGnKDEC4ZKfKJVc=", + "lastModified": 1676243887, + "narHash": "sha256-iZV4n5rbnFaVg03HBxOYQym1FTH1TL1YxLptoLizACs=", "owner": "maralorn", "repo": "nix-output-monitor", - "rev": "9345278323e8763ca04ede5429c72655c4cef0bf", + "rev": "e0c5df1056532aa1beba173825ad61a495b3274f", "type": "github" }, "original": { @@ -770,11 +831,11 @@ }, "nur": { "locked": { - "lastModified": 1673661479, - "narHash": "sha256-zdM1dKVrtQyHfMUKQJSrm1xrQbdrA4yFdS/bODZSHPs=", + "lastModified": 1676619352, + "narHash": "sha256-a9pQbtOcUYS9boD6+lQqPe0WzME0x8yzZk365w9XGbM=", "owner": "nix-community", "repo": "NUR", - "rev": "dcb9bbb764666a4ecc94d8319aed1ffb5f8efe82", + "rev": "d2d70316f27384cf53e0f3c6cf2fd73e4744555a", "type": "github" }, "original": { @@ -783,9 +844,25 @@ "type": "github" } }, + "panfork": { + "flake": false, + "locked": { + "lastModified": 1670633863, + "narHash": "sha256-4eZHMiYS+sRDHNBtLZTA8ELZnLns7yT3USU5YQswxQ0=", + "owner": "panfork", + "repo": "mesa", + "rev": "120202c675749c5ef81ae4c8cdc30019b4de08f4", + "type": "gitlab" + }, + "original": { + "owner": "panfork", + "repo": "mesa", + "type": "gitlab" + } + }, "pre-commit-hooks": { "inputs": { - "flake-compat": "flake-compat_3", + "flake-compat": "flake-compat_2", "flake-utils": [ "nom", "flake-utils" @@ -811,40 +888,23 @@ "type": "github" } }, - "preCommitHooks": { - "inputs": { - "flake-compat": "flake-compat_4", - "flake-utils": "flake-utils_4", - "gitignore": "gitignore_2", - "nixpkgs": "nixpkgs_6", - "nixpkgs-stable": "nixpkgs-stable_2" - }, - "locked": { - "lastModified": 1673627351, - "narHash": "sha256-oppRxEg/7ICcG67ErBvu1UlXt3su6zMcNoQmKaHPs5I=", - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "496e4505c2ddf5f205242eae8064d7d89cd976c0", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "type": "github" - } - }, "rock5b": { "inputs": { "fan-control": "fan-control", + "flake-parts": "flake-parts_4", "kernel-src": "kernel-src", - "nixpkgs": "nixpkgs_7" + "nixpkgs": "nixpkgs_7", + "nixpkgs-kernel": "nixpkgs-kernel", + "panfork": "panfork", + "tow-boot": "tow-boot", + "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1672309501, - "narHash": "sha256-M6LqzxQwBP9aMI1hCxfL0OwWinqx3NEXlU/8UlwtxFY=", + "lastModified": 1678619682, + "narHash": "sha256-Om3Pe5Rss96jVh8Ncq72eFyu/ev8UO3iZZC8R0n2iAs=", "owner": "aciceri", "repo": "rock5b-nixos", - "rev": "50e282f459462711be939175285a0a4c83649ab6", + "rev": "ba79eb513a6db741b9c9d3b717ea5f7a36ff4812", "type": "github" }, "original": { @@ -858,15 +918,17 @@ "agenix": "agenix", "ccrEmacs": "ccrEmacs", "comma": "comma", + "flake-parts": "flake-parts_2", "helix": "helix", "homeManager": "homeManager", + "nil": "nil", "nixosHardware": "nixosHardware", "nixpkgsStable": "nixpkgsStable", "nixpkgsUnstable": "nixpkgsUnstable", "nom": "nom", "nur": "nur", - "preCommitHooks": "preCommitHooks", - "rock5b": "rock5b" + "rock5b": "rock5b", + "treefmt-nix": "treefmt-nix_2" } }, "rust-overlay": { @@ -891,6 +953,89 @@ "type": "github" } }, + "rust-overlay_2": { + "inputs": { + "flake-utils": [ + "nil", + "flake-utils" + ], + "nixpkgs": [ + "nil", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1675391458, + "narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "tow-boot": { + "flake": false, + "locked": { + "lastModified": 1677346757, + "narHash": "sha256-3SKlcZhfUaNz1bd/l/1B3D66NUk3sALVIyP8DHv41SU=", + "owner": "aciceri", + "repo": "Tow-Boot", + "rev": "85d099f3473effdeca409bd165175d64dfb37ecc", + "type": "github" + }, + "original": { + "owner": "aciceri", + "ref": "rock5b", + "repo": "Tow-Boot", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "rock5b", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1678277086, + "narHash": "sha256-fQ1G72KhLWWf2z+ug9+4ErTEayvlcVQMul0qusKKBgk=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "ec39cfa24342fdf0b04ae44592a191c4765f9c74", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, + "treefmt-nix_2": { + "inputs": { + "nixpkgs": [ + "nixpkgsUnstable" + ] + }, + "locked": { + "lastModified": 1678616506, + "narHash": "sha256-JBlOlpPj7VtzFTApEHioFl8YSVhyT0dMgymV8t7sW1g=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "5ec73d38dde4c766a9ae19840fc6afa724096f00", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, "utils": { "locked": { "lastModified": 1659877975, diff --git a/flake.nix b/flake.nix index f241ef2..200e510 100644 --- a/flake.nix +++ b/flake.nix @@ -2,57 +2,53 @@ description = "A complete, declarative, and reproducible configuration of my entire Nix fleet"; inputs = { - nixpkgsUnstable.url = "github:NixOS/nixpkgs"; - nixpkgsStable.url = "github:NixOS/nixpkgs/nixos-22.05"; + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgsUnstable.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgsStable.url = "github:NixOS/nixpkgs/nixos-22.11"; nixosHardware.url = "github:NixOS/nixos-hardware"; homeManager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgsUnstable"; }; nur.url = "github:nix-community/NUR"; - preCommitHooks.url = "github:cachix/pre-commit-hooks.nix"; agenix.url = "github:ryantm/agenix"; comma.url = "github:nix-community/comma"; rock5b.url = "github:aciceri/rock5b-nixos"; ccrEmacs.url = "github:aciceri/emacs"; helix.url = "github:helix-editor/helix"; + nil.url = "github:oxalica/nil"; nom.url = "github:maralorn/nix-output-monitor"; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgsUnstable"; + }; }; - outputs = {self, ...} @ inputs: let - utils = import ./utils inputs; - inherit - (utils) - checkFormatting - formatApp - formatter - lib - mkDevShell - mkVmApps - nixosConfigurations - ; - in { - inherit nixosConfigurations; - apps = lib.foldr lib.recursiveUpdate {} [ - (mkVmApps self.nixosConfigurations) - formatApp - ]; - - checks = checkFormatting ./.; - - devShells = mkDevShell; - - inherit formatter; - }; + outputs = inputs @ {flake-parts, ...}: + flake-parts.lib.mkFlake {inherit inputs;} { + imports = [ + # ./modules + # ./hmModules + ./hosts + ./packages + ./shell + ./formatting + ]; + systems = ["x86_64-linux" "aarch64-linux"]; + }; nixConfig = { extra-substituters = [ + "https://nix-community.cachix.org" "https://aciceri-fleet.cachix.org" + "https://aciceri-emacs.cachix.org" "https://rock5b-nixos.cachix.org" "https://helix.cachix.org" ]; extra-trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "aciceri-fleet.cachix.org-1:e1AodrwmzRWy0eQi3lUY71M41fp9Sq+UpuKKv705xsI=" + "aciceri-emacs.cachix.org-1:kxDGDFWV6LUj41tb8xmPRBI56UJSZOVveN49LZDUKdA=" "rock5b-nixos.cachix.org-1:bXHDewFS0d8pT90A+/YZan/3SjcyuPZ/QRgRSuhSPnA=" "helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs=" ]; diff --git a/formatting/default.nix b/formatting/default.nix new file mode 100644 index 0000000..cba0a79 --- /dev/null +++ b/formatting/default.nix @@ -0,0 +1,11 @@ +{inputs, ...}: { + imports = [ + inputs.treefmt-nix.flakeModule + ]; + perSystem = {pkgs, ...}: { + treefmt.config = { + projectRootFile = ".git/config"; + programs.alejandra.enable = true; + }; + }; +} diff --git a/hmModules/emacs/default.nix b/hmModules/emacs/default.nix index 9da7f30..d2860e3 100644 --- a/hmModules/emacs/default.nix +++ b/hmModules/emacs/default.nix @@ -1,3 +1,3 @@ -{ +{lib, ...}: { ccrEmacs.enable = true; } diff --git a/hmModules/firefox/default.nix b/hmModules/firefox/default.nix index c0d44d7..3d44c39 100644 --- a/hmModules/firefox/default.nix +++ b/hmModules/firefox/default.nix @@ -14,21 +14,21 @@ enableFXCastBridge = pkgs.system == "x86_64-linux"; }; }; - extensions = with pkgs.nur.repos.rycee.firefox-addons; [ - privacy-badger - ublock-origin - tridactyl - octotree - octolinker - org-capture - browserpass - bypass-paywalls-clean - ghosttext # or edit-with-emacs? - # fx_cast # TODO make PR to rycee NUR repo - ]; profiles.ccr = { + extensions = with pkgs.nur.repos.rycee.firefox-addons; [ + privacy-badger + ublock-origin + tridactyl + octotree + octolinker + org-capture + browserpass + bypass-paywalls-clean + ghosttext # or edit-with-emacs? + # fx_cast # TODO make PR to rycee NUR repo + ]; settings = { - "browser.startup.homepage" = "https://search.privatevoid.net/"; + "browser.startup.homepage" = "https://searx.be"; "browser.search.region" = "IT"; "browser.search.isUS" = false; "distribution.searchplugins.defaultLocale" = "it-IT"; diff --git a/hmModules/obs-studio/default.nix b/hmModules/obs-studio/default.nix new file mode 100644 index 0000000..6e527dc --- /dev/null +++ b/hmModules/obs-studio/default.nix @@ -0,0 +1,6 @@ +{pkgs, ...}: { + programs.obs-studio = { + enable = true; + plugins = with pkgs.obs-studio-plugins; [wlrobs input-overlay]; + }; +} diff --git a/hmModules/shell/default.nix b/hmModules/shell/default.nix index 0461afb..e80a267 100644 --- a/hmModules/shell/default.nix +++ b/hmModules/shell/default.nix @@ -14,7 +14,7 @@ nix-direnv.enable = true; }; - services.lorri.enable = true; + services.lorri.enable = false; # I'm not using it programs.exa = { enable = true; @@ -44,6 +44,55 @@ }; }; + # Playing with it sometimes + programs.nushell = { + enable = true; + configFile.text = '' + let-env config = { + show_banner: false + ls: { + use_ls_colors: true # use the LS_COLORS environment variable to colorize output + clickable_links: true # enable or disable clickable links. Your terminal has to support links. + } + rm: { + always_trash: true # always act as if -t was given. Can be overridden with -p + } + cd: { + abbreviations: true # allows `cd s/o/f` to expand to `cd some/other/folder` + } + table: { + mode: compact # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other + index_mode: always # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column + trim: { + methodology: wrapping # wrapping or truncating + wrapping_try_keep_words: true # A strategy used by the 'wrapping' methodology + truncating_suffix: "..." # A suffix used by the 'truncating' methodology + } + } + history: { + max_size: 10000 # Session has to be reloaded for this to take effect + sync_on_enter: true # Enable to share history between multiple sessions, else you have to close the session to write history to file + file_format: "plaintext" # "sqlite" or "plaintext" + } + completions: { + case_sensitive: false # set to true to enable case-sensitive completions + quick: true # set this to false to prevent auto-selecting completions when only one remains + partial: true # set this to false to prevent partial filling of the prompt + algorithm: "prefix" # prefix or fuzzy + external: { + enable: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up my be very slow + max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options + completer: null # check 'carapace_completer' above as an example + } + } + filesize: { + metric: true # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard) + format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, zb, zib, auto + } + } + ''; + }; + programs.zsh = { enable = true; enableAutosuggestions = true; @@ -84,9 +133,6 @@ initExtra = '' [[ -z $INSIDE_EMACS ]] && source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh ''; - sessionVariables = { - EDITOR = "hx"; - }; }; home.packages = with pkgs; [ @@ -95,6 +141,6 @@ dig.dnsutils zsh-completions nix-zsh-completions - nom + # nom # FIXME disable on aarch64-linux, breaks everything :( ]; } diff --git a/hmModules/sway/default.nix b/hmModules/sway/default.nix index 52facc6..6904105 100644 --- a/hmModules/sway/default.nix +++ b/hmModules/sway/default.nix @@ -48,11 +48,20 @@ output = let bg = "${./wallpaper.svg} fill"; in { - DP-1 = { + DP-2 = { + res = "1900x1200"; pos = "0 0"; inherit bg; + transform = "90"; + }; + DP-1 = { + res = "2560x1440"; + pos = "1200 230"; + inherit bg; }; eDP-1 = { + res = "1920x1080"; + pos = "3760 230"; inherit bg; }; }; @@ -97,16 +106,15 @@ ${pkgs.wf-recorder}/bin/wf-recorder -g "$coords" -f "$filename" wl-copy -t video/mp4 < $filename ''; - emacsclientAsTerminal = pkgs.writeShellScript "emacsclientAsTerminal" '' - emacsclient -c -F '\\'(name . "VTerm"))' -q --eval '\\'(vterm "/bin/zsh")' - ''; in lib.mkOptionDefault { "${modifier}+x" = "exec emacsclient -c"; "${modifier}+b" = "exec qutebrowser"; "${modifier}+s" = "exec ${screenshotScript}"; - "${modifier}+g" = "exec ${screenrecordingScript}"; - # "${modifier}+Shift+Enter" = "exec ${emacsclientAsTerminal}"; # FIXME + # "${modifier}+g" = "exec ${screenrecordingScript}"; # FIXME + "${modifier}+t" = '' + exec emacsclient -c -F "\'(name . \\"VTerm\\"))" -q --eval '(vterm (getenv "SHELL"))' + ''; "XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s +5%"; "XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl s 5%-"; }; diff --git a/hosts/default.nix b/hosts/default.nix new file mode 100644 index 0000000..e520126 --- /dev/null +++ b/hosts/default.nix @@ -0,0 +1,132 @@ +{ + self, + lib, + config, + inputs, + ... +}: { + options.fleet = { + hosts = lib.mkOption { + description = "Host configuration"; + type = lib.types.attrsOf (lib.types.submodule { + options = { + name = lib.mkOption { + description = "Host name"; + type = lib.types.strMatching "^$|^[[:alnum:]]([[:alnum:]_-]{0,61}[[:alnum:]])?$"; + }; + system = lib.mkOption { + description = "NixOS architecture (a.k.a. system)"; + type = lib.types.str; + default = "x86_64-linux"; + }; + secrets = lib.mkOption { + description = "List of secrets names in the `secrets` folder"; + type = lib.types.listOf lib.types.str; + default = []; + }; + enableHomeManager = lib.mkOption { + description = "Enable home-manager module"; + type = lib.types.bool; + default = true; + }; + overlays = lib.mkOption { + description = "Enabled Nixpkgs overlays"; + type = lib.types.listOf (lib.mkOptionType { + name = "nixpkgs-overlay"; + description = "nixpkgs overlay"; + check = lib.isFunction; + merge = lib.mergeOneOption; + }); + default = with inputs; [ + agenix.overlays.default + comma.overlays.default + nur.overlay + nil.overlays.default + ]; + }; + extraModules = lib.mkOption { + description = "Extra NixOS modules"; + type = lib.types.listOf lib.types.deferredModule; + default = []; + }; + extraHmModules = lib.mkOption { + description = "Extra home-manager modules"; + type = lib.types.listOf lib.types.deferredModule; + default = []; + }; + extraHmModulesUser = lib.mkOption { + description = "User for which to import extraHmModulesUser"; + type = lib.types.str; + default = "ccr"; + }; + }; + }); + default = {}; + }; + _mkNixosConfiguration = lib.mkOption { + description = "Function returning a proper NixOS configuration"; + type = lib.types.functionTo (lib.types.functionTo lib.types.attrs); # TODO improve this type + internal = true; + default = hostname: config: + inputs.nixpkgsUnstable.lib.nixosSystem { + system = config.system; + modules = + [ + ({lib, ...}: { + networking.hostName = lib.mkForce hostname; + nixpkgs.overlays = config.overlays; + }) + "${self.outPath}/hosts/${hostname}" + ] + ++ (lib.optionals (config.secrets != []) [ + inputs.agenix.nixosModules.default + ({lib, ...}: { + age.secrets = + lib.filterAttrs + (name: _: builtins.elem name config.secrets) + (lib.mapAttrs' (name: _: { + name = lib.removeSuffix ".age" (builtins.baseNameOf name); + value.file = "${self.outPath}/${name}"; + }) (import "${self.outPath}/secrets")); + }) + ]) + ++ (lib.optionals config.enableHomeManager [ + inputs.homeManager.nixosModule + {home-manager.users."${config.extraHmModulesUser}".imports = config.extraHmModules;} + ]) + ++ config.extraModules; + specialArgs = { + fleetModules = builtins.map (moduleName: "${self.outPath}/modules/${moduleName}"); + fleetHmModules = builtins.map (moduleName: "${self.outPath}/hmModules/${moduleName}"); + }; + }; + }; + }; + + # TODO Add per host: + # - apps to run as VMs + # - checks + # - deploy scripts (`nixos-rebuild`) + + config = { + fleet.hosts = { + # TODO add `hs` and `pbp` + thinkpad = { + extraModules = [inputs.nixosHardware.nixosModules.lenovo-thinkpad-x1-7th-gen]; + extraHmModules = [ + inputs.ccrEmacs.hmModules.default + ]; + secrets = ["cachix"]; + }; + rock5b = { + system = "aarch64-linux"; + extraModules = [inputs.rock5b.nixosModules.default]; + }; + }; + + flake.nixosConfigurations = + lib.mapAttrs + config.fleet._mkNixosConfiguration + config.fleet.hosts; + }; +} diff --git a/hosts/rock5b/default.nix b/hosts/rock5b/default.nix index e63f604..e98d1ff 100644 --- a/hosts/rock5b/default.nix +++ b/hosts/rock5b/default.nix @@ -1,13 +1,72 @@ -{fleetModules, ...}: { +{ + fleetModules, + lib, + pkgs, + config, + ... +}: { imports = [ ./hardware-configuration.nix ] - ++ fleetModules [ + ++ (fleetModules [ "common" "ssh" "ccr" - ]; + ]); ccr.enable = true; + + services.rock5b-fan-control.enable = true; + + nixpkgs.config.permittedInsecurePackages = [ + "libav-11.12" + ]; + + fileSystems."/mnt/film" = { + device = "//ccr.ydns.eu/film"; + fsType = "cifs"; + options = let + credentials = pkgs.writeText "credentials" '' + username=guest + password= + ''; + in ["credentials=${credentials},x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s"]; + }; + fileSystems."/mnt/archivio" = { + device = "//ccr.ydns.eu/archivio"; + fsType = "cifs"; + options = let + credentials = pkgs.writeText "credentials" '' + username=guest + password= + ''; + in ["credentials=${credentials},x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s"]; + }; + + environment.systemPackages = with pkgs; [ + kodi-rock5b + cifs-utils + ]; + + users.extraUsers.kodi = { + isNormalUser = true; + uid = 1002; + extraGroups = ["video" "input"]; + }; + + # Waiting for https://github.com/NixOS/nixpkgs/issues/140304 + services.getty = let + script = pkgs.writeText "login-program.sh" '' + if [[ "$(tty)" == '/dev/tty1' ]]; then + ${pkgs.shadow}/bin/login -f kodi; + else + ${pkgs.shadow}/bin/login; + fi + ''; + in { + loginProgram = "${pkgs.bash}/bin/sh"; + loginOptions = toString script; + extraArgs = ["--skip-login"]; + }; } diff --git a/hosts/rock5b/hardware-configuration.nix b/hosts/rock5b/hardware-configuration.nix index cf15a14..670ddbc 100644 --- a/hosts/rock5b/hardware-configuration.nix +++ b/hosts/rock5b/hardware-configuration.nix @@ -6,6 +6,8 @@ }; }; + nixpkgs.hostPlatform = "aarch64-linux"; + swapDevices = []; boot.loader = { diff --git a/hosts/thinkpad/default.nix b/hosts/thinkpad/default.nix index e2b2514..e007a24 100644 --- a/hosts/thinkpad/default.nix +++ b/hosts/thinkpad/default.nix @@ -14,7 +14,7 @@ "adb" "audio" "battery" - "binfmt" + # "binfmt" "bluetooth" "ccr" "common" @@ -29,6 +29,7 @@ "udisks2" "xdg" "nix-development" + "clamav" ]; ccr = { @@ -58,6 +59,7 @@ "xdg" "zathura" "chrome" + "obs-studio" ]; packages = with pkgs; [ comma @@ -78,7 +80,7 @@ boot.initrd.availableKernelModules = ["xhci_pci" "nvme" "usb_storage" "sd_mod"]; boot.initrd.kernelModules = []; boot.kernelModules = ["kvm-intel"]; - boot.extraModulePackages = []; + boot.extraModulePackages = with config.boot.kernelPackages; [v4l2loopback]; boot.kernelPackages = pkgs.linuxPackages_zen; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking diff --git a/modules/clamav/default.nix b/modules/clamav/default.nix new file mode 100644 index 0000000..382a8ad --- /dev/null +++ b/modules/clamav/default.nix @@ -0,0 +1,10 @@ +{ + services.clamav = { + daemon.enable = true; + updater = { + enable = true; + frequency = 1; + interval = "daily"; + }; + }; +} diff --git a/modules/kodi/default.nix b/modules/kodi/default.nix index b3e89c1..1eb104e 100644 --- a/modules/kodi/default.nix +++ b/modules/kodi/default.nix @@ -32,47 +32,47 @@ allowedUDPPorts = [8080]; }; - environment.systemPackages = with pkgs; [xboxdrv cifs-utils]; - fileSystems."/mnt/film" = { - device = "//ccr.ydns.eu/film"; - fsType = "cifs"; - options = let - credentials = pkgs.writeText "credentials" '' - username=guest - password= - ''; - in ["credentials=${credentials},x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s"]; - }; - fileSystems."/mnt/archivio" = { - device = "//ccr.ydns.eu/archivio"; - fsType = "cifs"; - options = let - credentials = pkgs.writeText "credentials" '' - username=guest - password= - ''; - in ["credentials=${credentials},x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s"]; - }; + # environment.systemPackages = with pkgs; [xboxdrv cifs-utils]; + # fileSystems."/mnt/film" = { + # device = "//ccr.ydns.eu/film"; + # fsType = "cifs"; + # options = let + # credentials = pkgs.writeText "credentials" '' + # username=guest + # password= + # ''; + # in ["credentials=${credentials},x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s"]; + # }; + # fileSystems."/mnt/archivio" = { + # device = "//ccr.ydns.eu/archivio"; + # fsType = "cifs"; + # options = let + # credentials = pkgs.writeText "credentials" '' + # username=guest + # password= + # ''; + # in ["credentials=${credentials},x-systemd.automount,noauto,x-systemd.idle-timeout=60,x-systemd.device-timeout=5s,x-systemd.mount-timeout=5s"]; + # }; - systemd.services.xboxdrv = { - wantedBy = ["multi-user.target"]; - after = ["network.target"]; - serviceConfig = { - Type = "forking"; - User = "root"; - ExecStart = ''${pkgs.xboxdrv}/bin/xboxdrv --daemon --detach --pid-file /var/run/xboxdrv.pid --dbus disabled --silent --deadzone 4000 --deadzone-trigger 10% --mimic-xpad-wireless''; - }; - }; + # systemd.services.xboxdrv = { + # wantedBy = ["multi-user.target"]; + # after = ["network.target"]; + # serviceConfig = { + # Type = "forking"; + # User = "root"; + # ExecStart = ''${pkgs.xboxdrv}/bin/xboxdrv --daemon --detach --pid-file /var/run/xboxdrv.pid --dbus disabled --silent --deadzone 4000 --deadzone-trigger 10% --mimic-xpad-wireless''; + # }; + # }; - services.xserver.config = '' - Section "InputClass" - Identifier "joystick catchall" - MatchIsJoystick "on" - MatchDevicePath "/dev/input/event*" - Driver "evdev" - Option "StartKeysEnabled" "False" - Option "StartMouseEnabled" "False" - EndSection - ''; - boot.blacklistedKernelModules = ["xpad"]; + # services.xserver.config = '' + # Section "InputClass" + # Identifier "joystick catchall" + # MatchIsJoystick "on" + # MatchDevicePath "/dev/input/event*" + # Driver "evdev" + # Option "StartKeysEnabled" "False" + # Option "StartMouseEnabled" "False" + # EndSection + # ''; + # boot.blacklistedKernelModules = ["xpad"]; } diff --git a/modules/nix/default.nix b/modules/nix/default.nix index 5b093ba..edceeb9 100644 --- a/modules/nix/default.nix +++ b/modules/nix/default.nix @@ -38,13 +38,4 @@ optimise.automatic = true; }; - - age.secrets.cachix.file = ../../secrets/cachix.age; - system.activationScripts = { - populate-netrc.text = '' - cat < /etc/nix/netrc - machine mlabs.cachix.org login x password "$(cat ${config.age.secrets.cachix.path})" - EOF - ''; - }; } diff --git a/packages/default.nix b/packages/default.nix new file mode 100644 index 0000000..3851f20 --- /dev/null +++ b/packages/default.nix @@ -0,0 +1,37 @@ +{ + inputs, + lib, + config, + ... +}: { + options.fleet.overlays = let + overlayType = lib.mkOptionType { + name = "nixpkgs-overlay"; + description = "nixpkgs overlay"; + check = lib.isFunction; + merge = lib.mergeOneOption; + }; + in + lib.mkOption { + description = "Nixpkgs overlays to apply at flake level (not in hosts)"; + type = lib.types.listOf overlayType; + default = with inputs; [ + agenix.overlays.default + comma.overlays.default + nur.overlay + nil.overlays.default + ]; + }; + + config.perSystem = { + system, + lib, + ... + }: { + _module.args.pkgs = + lib.foldl + (legacyPackages: overlay: legacyPackages.extend overlay) + inputs.nixpkgsUnstable.legacyPackages.${system} + config.fleet.overlays; + }; +} diff --git a/shell/default.nix b/shell/default.nix new file mode 100644 index 0000000..3a9acc2 --- /dev/null +++ b/shell/default.nix @@ -0,0 +1,19 @@ +{inputs, ...}: { + perSystem = { + pkgs, + config, + self', + ... + }: { + devShells.default = pkgs.mkShell { + name = "fleet-shell"; + buildInputs = with pkgs; [ + git + agenix + ]; + shellHook = '' + export RULES="$(git rev-parse --show-toplevel)/secrets/default.nix"; + ''; + }; + }; +} diff --git a/utils/default.nix b/utils/default.nix deleted file mode 100644 index 72bb5f6..0000000 --- a/utils/default.nix +++ /dev/null @@ -1,172 +0,0 @@ -{ - agenix, - comma, - homeManager, - nixosHardware, - nixpkgsUnstable, - nur, - preCommitHooks, - rock5b, - helix, - nom, - ccrEmacs, - self, - ... -}: let - supportedSystems = { - x86_64-linux = "x86_64-linux"; - aarch64-linux = "aarch64-linux"; - }; - - pkgsFor = lib.genAttrs (lib.attrValues supportedSystems) (system: nixpkgsUnstable.legacyPackages.${system}); - - lib = nixpkgsUnstable.lib.extend (self: super: { - perSystem = super.genAttrs (super.attrValues supportedSystems); - }); - - mkConfiguration = { - name, - system, - modules ? [], - }: - lib.nixosSystem { - inherit system; - modules = - [ - ({pkgs, ...}: { - networking.hostName = lib.mkForce name; - home-manager.users.ccr.imports = [ - ccrEmacs.hmModules.default - ]; - age = { - identityPaths = ["/home/ccr/.ssh/id_rsa"]; - secrets = lib.mapAttrs' (name: _: { - name = lib.removeSuffix ".age" (builtins.baseNameOf name); - value.file = ./.. + "/${name}"; - }) (import ../secrets); - }; - nixpkgs.overlays = [ - agenix.overlay - comma.overlays.default - nur.overlay - (_: self: { - helix = helix.packages.${pkgs.system}.helix-dev; - nom = nom.packages.${pkgs.system}.default or (self.runCommandLocal "empty" {} "touch $out"); - }) - ]; - }) - (../hosts + "/${name}") - homeManager.nixosModule - agenix.nixosModule - ] - ++ modules; - specialArgs = { - # The following paths (../modules and ../hmModules) are relative to the location - # where they are imported, *not* from here - fleetModules = moduleNames: builtins.map (moduleName: ../modules + "/${moduleName}") moduleNames; - fleetHmModules = moduleNames: builtins.map (moduleName: ../hmModules + "/${moduleName}") moduleNames; - }; - }; - - nixosConfigurations = { - thinkpad = mkConfiguration { - name = "thinkpad"; - system = supportedSystems.x86_64-linux; - modules = [nixosHardware.nixosModules.lenovo-thinkpad-x1-7th-gen]; - }; - hs = mkConfiguration { - name = "hs"; - system = supportedSystems.x86_64-linux; - }; - pbp = mkConfiguration { - name = "pbp"; - system = supportedSystems.aarch64-linux; - modules = ["${nixosHardware}/pine64/pinebook-pro"]; - }; - # Retired but it could be still usefull, so I'm not deleting it - # beebox = mkConfiguration { - # name = "beebox"; - # system = supportedSystems.x86_64-linux; - # }; - rock5b = mkConfiguration { - name = "rock5b"; - system = supportedSystems.aarch64-linux; - modules = [rock5b.nixosModules.kernel rock5b.nixosModules.fan-control]; - }; - }; - - mkVmApp = system: configuration: let - shellScript = pkgsFor.${system}.writeShellScript "run-vm" '' - ${configuration.config.system.build.vm}/bin/run-${configuration.config.networking.hostName}-vm - ''; - in { - type = "app"; - program = "${shellScript}"; - }; - - mkVmApps = configurations: - lib.perSystem (system: - lib.genAttrs (lib.attrNames configurations) ( - configurationName: - mkVmApp system configurations.${configurationName} - )); - - formatter = lib.perSystem (system: pkgsFor.${system}.alejandra); - - formatApp = lib.perSystem ( - system: { - format = { - type = "app"; - program = "${pkgsFor.${system}.alejandra}/bin/alejandra"; - }; - } - ); - - checkFormatting = flakePath: - lib.perSystem ( - system: let - pkgs = pkgsFor.${system}; - in { - check-nix-formatting = pkgs.runCommand "check-nix-formatting" {buildInputs = [pkgs.alejandra];} "alejandra --check ${flakePath} > $out"; - } - ); - - checkFormattingHook = lib.perSystem ( - system: { - nix = preCommitHooks.lib.${system}.run { - src = self; - hooks.alejandra = { - enable = true; - entry = lib.mkForce formatApp.${system}.format.program; - }; - }; - } - ); - - mkDevShell = lib.perSystem (system: let - pkgs = pkgsFor.${system}; - in { - default = pkgs.mkShell { - shellHook = - checkFormattingHook.${system}.nix.shellHook - + '' - export RULES="$(git rev-parse --show-toplevel)/secrets/default.nix"; - ''; - packages = with pkgs; [ - git - agenix.packages.${system}.agenix - ]; - }; - }); -in { - inherit - checkFormatting - formatApp - formatter - lib - mkDevShell - mkVmApps - nixosConfigurations - supportedSystems - ; -}