diff options
| author | seth <[email protected]> | 2024-08-06 20:32:29 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2024-08-06 20:32:29 -0400 |
| commit | 7c328ba30596970af40e3bade54621ecfa3e7ad1 (patch) | |
| tree | 7f6665aaa47946fa1bd77141fbb90ef714e3a8e3 | |
initial commit
| -rw-r--r-- | .github/dependabot.yml | 8 | ||||
| -rw-r--r-- | .github/workflows/ci.yaml | 78 | ||||
| -rw-r--r-- | .gitignore | 80 | ||||
| -rw-r--r-- | LICENSE | 9 | ||||
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | configuration/busybox.nix | 4 | ||||
| -rw-r--r-- | configuration/default.nix | 19 | ||||
| -rw-r--r-- | configuration/minimal.nix | 9 | ||||
| -rw-r--r-- | configuration/module-fixes.nix | 18 | ||||
| -rw-r--r-- | flake.lock | 27 | ||||
| -rw-r--r-- | flake.nix | 56 |
11 files changed, 311 insertions, 0 deletions
diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4c39a33 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + commit-message: + prefix: "ci" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..f6eb351 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,78 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +jobs: + build: + name: Build (${{ matrix.system }}) + + strategy: + fail-fast: false + matrix: + include: + - system: x86_64-linux + os: ubuntu-latest + + runs-on: ${{ matrix.os }} + + steps: + # https://github.com/actions/runner-images/issues/2840#issuecomment-790492173 + - name: Clear disk space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf /usr/local/share/boost + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v13 + with: + diagnostic-endpoint: "" + + - name: Setup Cache + uses: DeterminateSystems/magic-nix-cache-action@v7 + + - name: Run build + run: | + nix run \ + --inputs-from . \ + nixpkgs#nix-fast-build -- \ + --no-nom \ + --option allow-import-from-derivation false + + format: + name: Format + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v13 + with: + diagnostic-endpoint: "" + + - name: Check formatting + run: nix fmt -- --check . + + build-gate: + name: Build gate + needs: [build, format] + + if: always() + + runs-on: ubuntu-latest + + steps: + - name: Exit with error + if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') + run: exit 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1c14774 --- /dev/null +++ b/.gitignore @@ -0,0 +1,80 @@ +### Nix +result +result-* +repl-result-* + +### https://raw.github.com/github/gitignore/8779ee73af62c669e7ca371aaab8399d87127693/Global/Windows.gitignore + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + + +### https://raw.github.com/github/gitignore/8779ee73af62c669e7ca371aaab8399d87127693/Global/Linux.gitignore + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + + +### https://raw.github.com/github/gitignore/8779ee73af62c669e7ca371aaab8399d87127693/Global/macOS.gitignore + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon
+ +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2024 seth + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..be19c39 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# nixos-musl-flake + +A small experiment in combining NixOS, musl, busybox, and other hipster trash diff --git a/configuration/busybox.nix b/configuration/busybox.nix new file mode 100644 index 0000000..d9135eb --- /dev/null +++ b/configuration/busybox.nix @@ -0,0 +1,4 @@ +{ pkgs, ... }: +{ + environment.systemPackages = [ pkgs.busybox ]; +} diff --git a/configuration/default.nix b/configuration/default.nix new file mode 100644 index 0000000..1a5b2da --- /dev/null +++ b/configuration/default.nix @@ -0,0 +1,19 @@ +{ + imports = [ + ./busybox.nix + ./minimal.nix # Making this configuration a bit smaller to save on build time & download size + ./module-fixes.nix # Module-level fixes for musl + ]; + + boot.loader.systemd-boot.enable = true; + + fileSystems = { + "/" = { + device = "none"; + fsType = "ramfs"; + }; + }; + + # You probably know the drill. Don't change this. + system.stateVersion = "24.11"; +} diff --git a/configuration/minimal.nix b/configuration/minimal.nix new file mode 100644 index 0000000..ff0ebc2 --- /dev/null +++ b/configuration/minimal.nix @@ -0,0 +1,9 @@ +{ modulesPath, ... }: +{ + imports = [ + # The configuration is mainly for testing. We don't need to actually use much + (modulesPath + "/profiles/minimal.nix") + # This includes perl + (modulesPath + "/profiles/perlless.nix") + ]; +} diff --git a/configuration/module-fixes.nix b/configuration/module-fixes.nix new file mode 100644 index 0000000..ee3005c --- /dev/null +++ b/configuration/module-fixes.nix @@ -0,0 +1,18 @@ +{ pkgs, ... }: +{ + environment = { + # NOTE: This is what prints the fun error message about + # binaries not compiled for NixOS not working with it + # + # It's here because on x86_64 systems, a 32-bit `ld` stub + # is built against `pkgs.pkgsi686Linux`; nixpkgs doesn't + # support a pure i686 musl bootstrap, so it throws an eval + # error. womp womp + stub-ld.enable = false; + }; + + # HACK: nixpkgs instantiated for musl doesn't have glibc locales, so the + # default value throws eval errors + # This will probably break something + i18n.glibcLocales = pkgs.emptyFile; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..04466fa --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1722813957, + "narHash": "sha256-IAoYyYnED7P8zrBFMnmp7ydaJfwTnwcnqxUElC1I26Y=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "cb9a96f23c491c081b38eab96d22fa958043c9fa", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..70c1d19 --- /dev/null +++ b/flake.nix @@ -0,0 +1,56 @@ +{ + description = "A small experiment in combining NixOS, musl, busybox, and other hipster trash"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = + { self, nixpkgs }: + let + inherit (nixpkgs) lib; + inherit (lib.systems.parse) abis tripleFromSystem; + + systems = [ + "x86_64-linux" + "aarch64-linux" + ]; + + forAllSystems = lib.genAttrs systems; + nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system}); + + # Get some extra information about all of our systems to use later + parsedFor = forAllSystems (system: (lib.systems.elaborate system).parsed); + + # nixpkgs defaults to gnu/glibc when elaborating Linux doubles like + # `x86_64-linux`. Make it use musl instead + muslSystemFor = forAllSystems (system: parsedFor.${system} // { abi = abis.musl; }); + + muslConfigurationFor = forAllSystems ( + system: + lib.nixosSystem { + modules = [ + ./configuration + # Make sure our system configuration is built for musl + { nixpkgs.hostPlatform.config = tripleFromSystem muslSystemFor.${system}; } + ]; + } + ); + in + { + checks = forAllSystems ( + system: + let + cpuArch = parsedFor.${system}.cpu.name; + in + { + configuration = self.nixosConfigurations."musl-${cpuArch}".config.system.build.vm; + } + ); + + formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style); + + nixosConfigurations = { + musl-x86_64 = muslConfigurationFor.x86_64-linux; + musl-aarch64 = muslConfigurationFor.aarch64-linux; + }; + }; +} |
