summary refs log tree commit diff
path: root/default.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-08-18 10:34:28 +0000
committerAlyssa Ross <hi@alyssa.is>2021-11-08 14:03:05 +0000
commitddd80babeeca39357b14fc8b670405dfd47a5a94 (patch)
treea85d5eadc426c88d903003523c214e2bec5cff4a /default.nix
downloadspectrum-ddd80babeeca39357b14fc8b670405dfd47a5a94.tar
spectrum-ddd80babeeca39357b14fc8b670405dfd47a5a94.tar.gz
spectrum-ddd80babeeca39357b14fc8b670405dfd47a5a94.tar.bz2
spectrum-ddd80babeeca39357b14fc8b670405dfd47a5a94.tar.lz
spectrum-ddd80babeeca39357b14fc8b670405dfd47a5a94.tar.xz
spectrum-ddd80babeeca39357b14fc8b670405dfd47a5a94.tar.zst
spectrum-ddd80babeeca39357b14fc8b670405dfd47a5a94.zip
Initial commit
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix50
1 files changed, 50 insertions, 0 deletions
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..7799889
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: EUPL-1.2
+# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
+
+{ pkgs ? import <nixpkgs> {} }: with pkgs;
+
+let
+  inherit (lib) cleanSource cleanSourceWith concatMapStringsSep;
+
+  packages = [ busybox execline s6 s6-linux-utils s6-portable-utils s6-rc ];
+
+  packagesBin = runCommand "packages-bin" {} ''
+    mkdir -p $out/bin
+    ln -s ${concatMapStringsSep " " (p: "${p}/bin/*") packages} $out/bin
+  '';
+
+  packagesTar = runCommand "packages.tar" {} ''
+    cd ${packagesBin}
+    tar -cvf $out --verbatim-files-from \
+        -T ${writeReferencesToFile packagesBin} bin
+  '';
+in
+
+stdenv.mkDerivation {
+  name = "spectrum-rootfs";
+
+  src = cleanSourceWith {
+    filter = name: _type: name != "${toString ./.}/build";
+    src = cleanSource ./.;
+  };
+
+  nativeBuildInputs = [ s6-rc squashfs-tools-ng ];
+
+  PACKAGES_TAR = packagesTar;
+
+  postPatch = ''
+    mkdir $NIX_BUILD_TOP/empty
+    substituteInPlace Makefile --replace /var/empty $NIX_BUILD_TOP/empty
+  '';
+
+  installPhase = ''
+    cp build/rootfs.ext4 $out
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with lib; {
+    license = licenses.eupl12;
+    platforms = platforms.linux;
+  };
+}