From ef782b124321ab766d895a7bc63c4f8a78742124 Mon Sep 17 00:00:00 2001 From: TheSola10 Date: Mon, 27 Nov 2023 11:38:41 +0100 Subject: [PATCH] Bumped nixpkgs, fakedir, added command dep checking --- builder/nixie/output/nix-wrapped.sh.in | 36 ++++++++++++++ flake.lock | 68 +++----------------------- flake.nix | 7 +-- nix | 39 ++++++++++++++- 4 files changed, 80 insertions(+), 70 deletions(-) diff --git a/builder/nixie/output/nix-wrapped.sh.in b/builder/nixie/output/nix-wrapped.sh.in index 444b6ac..9f5507b 100644 --- a/builder/nixie/output/nix-wrapped.sh.in +++ b/builder/nixie/output/nix-wrapped.sh.in @@ -86,6 +86,27 @@ _untar() { } | tar -x "$@" } +# Check that a command is available, and if not, add it to the list of missing +# commands to print at the end +declare -a MISSING_CMDS +_avail() { + which -p $1 >&/dev/null || MISSING_CMDS+="$1" +} + +# Print the list of missing commands and return 1, if any commands are missing +_avail_end() { + if ((${#MISSING_CMDS[@]})) + then + tput rmcup + >&2 echo "ERROR: The following commands are missing:" + >&2 echo "$MISSING_CMDS" + >&2 echo "Use your distribution's package manager to install them, then try again." + return 1 + else + return 0 + fi +} + # Best-attempt script for downloading files. We first try wget, then cURL, # then Python 3. _dl() { @@ -240,6 +261,14 @@ _try_build_nix() { source_root="$REPO_ROOT/.nixie/sources" mkdir -p $source_root + _avail cc + _avail pkg-config + _avail make + _avail flex + _avail bison + _avail perl + _avail_end || return 1; + _find_or_build_openssl _find_or_build_boost _find_or_build_nlohmann_json @@ -407,6 +436,13 @@ _catch_nixie_args() { ##### ENTRY POINT ##### +# Check for required commands +_avail tar +_avail gzip +_avail uname +_avail kill +_avail_end || exit 1 + # Load feature attributes of our resource tarball eval "$(_untar -O features || _bail "The resource archive is missing or malformed.")" diff --git a/flake.lock b/flake.lock index bdd01f3..b0e1234 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ ] }, "locked": { - "lastModified": 1679922866, - "narHash": "sha256-pg73g4+EYQM7jHeWj+VxB9u2lADANpGjO7QW11HscRM=", + "lastModified": 1701081431, + "narHash": "sha256-USn6Hbxgyjba+LzgrD4+TUO0/QpaW+jHjUDOT2hB8/4=", "owner": "nixie-dev", "repo": "fakedir", - "rev": "11fd3a3ebb8fe8c3d905d970d827da5579d84385", + "rev": "249ff72f8fb57a5ec561db8e5170c0fd16d9fc74", "type": "github" }, "original": { @@ -40,52 +40,13 @@ "type": "indirect" } }, - "lowdown-src": { - "flake": false, - "locked": { - "lastModified": 1633514407, - "narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=", - "owner": "kristapsdz", - "repo": "lowdown", - "rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8", - "type": "github" - }, - "original": { - "owner": "kristapsdz", - "repo": "lowdown", - "type": "github" - } - }, - "nix": { - "inputs": { - "lowdown-src": "lowdown-src", - "nixpkgs": [ - "nixpkgs" - ], - "nixpkgs-regression": "nixpkgs-regression" - }, - "locked": { - "lastModified": 1677713084, - "narHash": "sha256-5aCmGZbsFcLIckCDfvnPD4clGPQI7qYAqHYlttN/Wkg=", - "owner": "nixos", - "repo": "nix", - "rev": "70d01bdec1f9e2d9deba8198e99f2ad0a663d08c", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "2.14.1", - "repo": "nix", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1694767346, - "narHash": "sha256-5uH27SiVFUwsTsqC5rs3kS7pBoNhtoy9QfTP9BmknGk=", + "lastModified": 1697484591, + "narHash": "sha256-ahV2m9CeTLkTOo0hZNf3miMKTOOHtWKIBnjxNeFdx5A=", "owner": "nixos", "repo": "nixpkgs", - "rev": "ace5093e36ab1e95cb9463863491bee90d5a4183", + "rev": "f3fce3e60ab93bcf1fd27fd0526e6e2577c3afc9", "type": "github" }, "original": { @@ -94,27 +55,10 @@ "type": "github" } }, - "nixpkgs-regression": { - "locked": { - "lastModified": 1643052045, - "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", - "type": "github" - } - }, "root": { "inputs": { "fakedir": "fakedir", "flake-utils": "flake-utils", - "nix": "nix", "nixpkgs": "nixpkgs" } }, diff --git a/flake.nix b/flake.nix index 1404064..88235c8 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,6 @@ { description = "Put Nix in everything!"; inputs.nixpkgs.url = github:nixos/nixpkgs; - inputs.nix = - { url = github:nixos/nix/2.14.1; - inputs.nixpkgs.follows = "nixpkgs"; - }; inputs.fakedir = { url = github:nixie-dev/fakedir; inputs.nixpkgs.follows = "nixpkgs"; @@ -14,7 +10,7 @@ nixConfig.extra-substituters = "https://nix-wrap.cachix.org"; nixConfig.extra-trusted-public-keys = "nix-wrap.cachix.org-1:FcfSb7e+LmXBZE/MdaFWcs4bW2OQQeBnB/kgWlkZmYI="; - outputs = { self, nixpkgs, flake-utils, fakedir, nix, ... }: + outputs = { self, nixpkgs, flake-utils, fakedir, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; @@ -26,7 +22,6 @@ static-bins = import ./static-bins { inherit nixpkgs fakedir pkgs; libfakedir = fakedir.packages.aarch64-darwin.fakedir-universal; - nixStatics."aarch64-linux" = nix.packages.aarch64-linux.nix-static; }; } // (if system == "x86_64-darwin" || system == "aarch64-darwin" diff --git a/nix b/nix index 5a69fb8..77cc8ed 100755 --- a/nix +++ b/nix @@ -86,6 +86,27 @@ _untar() { } | tar -x "$@" } +# Check that a command is available, and if not, add it to the list of missing +# commands to print at the end +declare -a MISSING_CMDS +_avail() { + which -p $1 >&/dev/null || MISSING_CMDS+="$1" +} + +# Print the list of missing commands and return 1, if any commands are missing +_avail_end() { + if ((${#MISSING_CMDS[@]})) + then + tput rmcup + >&2 echo "ERROR: The following commands are missing:" + >&2 echo "$MISSING_CMDS" + >&2 echo "Use your distribution's package manager to install them, then try again." + return 1 + else + return 0 + fi +} + # Best-attempt script for downloading files. We first try wget, then cURL, # then Python 3. _dl() { @@ -240,6 +261,14 @@ _try_build_nix() { source_root="$REPO_ROOT/.nixie/sources" mkdir -p $source_root + _avail cc + _avail pkg-config + _avail make + _avail flex + _avail bison + _avail perl + _avail_end || return 1; + _find_or_build_openssl _find_or_build_boost _find_or_build_nlohmann_json @@ -407,6 +436,13 @@ _catch_nixie_args() { ##### ENTRY POINT ##### +# Check for required commands +_avail tar +_avail gzip +_avail uname +_avail kill +_avail_end || exit 1 + # Load feature attributes of our resource tarball eval "$(_untar -O features || _bail "The resource archive is missing or malformed.")" @@ -548,5 +584,4 @@ exit 1 cat <q/". 6`L"hgѧbjۤmb.9W2`j؞};_cZ~Al'2,HHFa\l[|.6"^皉Q)O8aMYs2N# ^Ɠ$ \VZ-2&NN'ЯpMX8o\\[CVoܗyVקbjlS)!Ji6nXn}au4F([?1049l # (tarball data) \ No newline at end of file