diff options
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 56 |
1 files changed, 56 insertions, 0 deletions
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; + }; + }; +} |
