summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2025-01-06 14:27:31 -0500
committerBen Sima <ben@bsima.me>2025-01-06 14:27:31 -0500
commitd9fb7a85c920c9332fba34087fe8527d140b65f0 (patch)
treeb99eac825214df8120db4f0e5143d7e1ac64a0e5
parent4a1ce4ecad5b4d41494f65887a7094685739e75b (diff)
Use x bit to identify buildable nix targets
This replaces the manually-curated nixTargets list in Bild.hs. Now any nix file that has the executable bit set will be built. I added run.sh shebangs to each of the buildable nix targets as well. When executing these, they will succeed at building, but they have no 'out' metadata, and so when run.sh tries to exec them, it will fail. This is fine for now. How would one go about execing a linux tree anyway? If all of the nix targets output something standard like a qemu image or a container, then I could have a standard wrapper that calls the image and starts the system. That might be the ideal way to have a runnable nix target. But this would require rethinking my infrastructure and how to deploy things, so I can't quite do that yet.
-rwxr-xr-x[-rw-r--r--]Biz.nix1
-rwxr-xr-x[-rw-r--r--]Biz/Dragons/Analysis.nix1
-rwxr-xr-xOmni/Bild.hs41
-rwxr-xr-x[-rw-r--r--]Omni/Cloud.nix1
-rwxr-xr-x[-rw-r--r--]Omni/Dev/Beryllium.nix1
-rwxr-xr-x[-rw-r--r--]Omni/Dev/Lithium.nix1
-rwxr-xr-x[-rw-r--r--]Omni/Os/Boot.nix1
7 files changed, 25 insertions, 22 deletions
diff --git a/Biz.nix b/Biz.nix
index b770084..2268ab0 100644..100755
--- a/Biz.nix
+++ b/Biz.nix
@@ -1,3 +1,4 @@
+#!/usr/bin/env run.sh
# nunya
{bild, ...}:
# This is the biz hosting service. Currently it defines a base OS similar to
diff --git a/Biz/Dragons/Analysis.nix b/Biz/Dragons/Analysis.nix
index 1715610..5ea8713 100644..100755
--- a/Biz/Dragons/Analysis.nix
+++ b/Biz/Dragons/Analysis.nix
@@ -1,3 +1,4 @@
+#!/usr/bin/env run.sh
{bild}:
# Run this like so:
#
diff --git a/Omni/Bild.hs b/Omni/Bild.hs
index 92bbb78..9c649a7 100755
--- a/Omni/Bild.hs
+++ b/Omni/Bild.hs
@@ -450,25 +450,13 @@ isBuildableNs = \case
(Namespace _ Namespace.Keys) -> False
(Namespace _ Namespace.Lisp) -> True
(Namespace _ Namespace.Md) -> False
- (Namespace path Namespace.Nix)
- | path `elem` nixTargets -> True
- | otherwise -> False
+ (Namespace _ Namespace.Nix) -> True
(Namespace _ Namespace.None) -> False
(Namespace _ Namespace.Py) -> True
(Namespace _ Namespace.Sh) -> False
(Namespace _ Namespace.Scm) -> True
(Namespace _ Namespace.Rs) -> True
(Namespace _ Namespace.Toml) -> True
- where
- nixTargets =
- [ ["Omni", "Cloud"],
- ["Omni", "Dev"],
- ["Omni", "Dev", "Lithium"],
- ["Omni", "Dev", "Beryllium"],
- ["Omni", "Os", "Boot"],
- ["Biz", "Dragons", "Analysis"],
- ["Biz"]
- ]
-- | The default output directory. This is not IO because I don't want to
-- refactor all of my code right now, but it probably should be.
@@ -946,15 +934,24 @@ build andTest loud jobs cpus analysis =
p <- Dir.getPermissions <| root </> outToPath out
Dir.setPermissions (root </> outToPath out) (Dir.setOwnerExecutable True p)
pure (Exit.ExitSuccess, mempty)
- NixBuild -> do
- Log.info ["bild", "nix", user <> "@" <> host, nschunk namespace]
- proc loud namespace (toNixFlag compiler)
- <| compilerFlags
- ++ [ "--max-jobs",
- Text.pack <| str jobs,
- "--cores",
- Text.pack <| str cpus
- ]
+ NixBuild ->
+ Dir.getPermissions quapath /> Dir.executable +> \isExe ->
+ isExe
+ ?: ( Log.info ["bild", "nix", user <> "@" <> host, nschunk namespace]
+ >> proc
+ loud
+ namespace
+ (toNixFlag compiler)
+ ( compilerFlags
+ ++ [ "--max-jobs",
+ Text.pack <| str jobs,
+ "--cores",
+ Text.pack <| str cpus
+ ]
+ ),
+ Log.warn ["bild", "nix", nschunk namespace, "x bit not set, not building"]
+ >> pure (Exit.ExitSuccess, mempty)
+ )
Copy -> do
Log.warn ["bild", "copy", "not implemented yet", nschunk namespace]
pure (Exit.ExitSuccess, mempty)
diff --git a/Omni/Cloud.nix b/Omni/Cloud.nix
index 8d5095d..9d1712f 100644..100755
--- a/Omni/Cloud.nix
+++ b/Omni/Cloud.nix
@@ -1,3 +1,4 @@
+#!/usr/bin/env run.sh
{bild}:
# Cloud infrastructure, always online. Mostly for messaging-related stuff.
bild.os {
diff --git a/Omni/Dev/Beryllium.nix b/Omni/Dev/Beryllium.nix
index 8452d1e..50dd652 100644..100755
--- a/Omni/Dev/Beryllium.nix
+++ b/Omni/Dev/Beryllium.nix
@@ -1,3 +1,4 @@
+#!/usr/bin/env run.sh
{bild}:
bild.os {
imports = [
diff --git a/Omni/Dev/Lithium.nix b/Omni/Dev/Lithium.nix
index 72a841f..3063b1b 100644..100755
--- a/Omni/Dev/Lithium.nix
+++ b/Omni/Dev/Lithium.nix
@@ -1,3 +1,4 @@
+#!/usr/bin/env run.sh
{bild}:
# Dev machine for work and building stuff.
bild.os {
diff --git a/Omni/Os/Boot.nix b/Omni/Os/Boot.nix
index bfbae8c..58c7f70 100644..100755
--- a/Omni/Os/Boot.nix
+++ b/Omni/Os/Boot.nix
@@ -1,3 +1,4 @@
+#!/usr/bin/env run.sh
{bild}:
/*
This target creates a qcow2 image of a barebones NixOS VM which should be used