diff --git a/default.nix b/default.nix deleted file mode 100644 index d211b81..0000000 --- a/default.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ lib, swift, swiftpm, swiftpm2nix, swiftPackages, ... }: - -let - # Pass the generated files to the helper. - generated = swiftpm2nix.helpers ./nix; - stdenv = swiftPackages.stdenv; -in - -stdenv.mkDerivation { - pname = "scopeddnsutil"; - version = "1.0.0"; - - src = ./.; - - # Including SwiftPM as a nativeBuildInput provides a buildPhase for you. - # This by default performs a release build using SwiftPM, essentially: - # swift build -c release - nativeBuildInputs = [ swift swiftpm ]; - - # The helper provides a configure snippet that will prepare all dependencies - # in the correct place, where SwiftPM expects them. - configurePhase = generated.configure; - - installPhase = '' - # This is a special function that invokes swiftpm to find the location - # of the binaries it produced. - binPath="$(swiftpmBinPath)" - # Now perform any installation steps. - mkdir -p $out/bin - cp $binPath/scopeddnsutil $out/bin/ - ''; - - LD_LIBRARY_PATH = lib.optionalString stdenv.hostPlatform.isLinux ( - lib.makeLibraryPath [ - swiftPackages.Dispatch - ] - ); - - # Allegedly this should work when XCTest is in buildInputs, but it doesn't - # doCheck = true; - - meta = with lib; { - platforms = platforms.all; - }; -} \ No newline at end of file diff --git a/flake.lock b/flake.lock index 45a5b84..c5cdaba 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,19 @@ { "nodes": { + "flake-schemas": { + "locked": { + "lastModified": 1721999734, + "narHash": "sha256-G5CxYeJVm4lcEtaO87LKzOsVnWeTcHGKbKxNamNWgOw=", + "rev": "0a5c42297d870156d9c57d8f99e476b738dcd982", + "revCount": 75, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/DeterminateSystems/flake-schemas/0.1.5/0190ef2f-61e0-794b-ba14-e82f225e55e6/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/DeterminateSystems/flake-schemas/%2A" + } + }, "nixpkgs": { "locked": { "lastModified": 1739923778, @@ -11,11 +25,12 @@ }, "original": { "type": "tarball", - "url": "https://flakehub.com/f/NixOS/nixpkgs/0.2411.%2A" + "url": "https://flakehub.com/f/NixOS/nixpkgs/%2A" } }, "root": { "inputs": { + "flake-schemas": "flake-schemas", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 8104e7c..9889449 100644 --- a/flake.nix +++ b/flake.nix @@ -1,21 +1,61 @@ +# This flake was initially generated by fh, the CLI for FlakeHub (version 0.1.18) { - description = "A tool to configure scoped DNS resolvers on macOS"; + # A helpful description of your flake + description = "Scoped DNS helper tool for macOS"; - inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2411.*"; + # Flake inputs + inputs = { + flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/*"; - outputs = { nixpkgs, ... }: + nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*"; + }; + + # Flake outputs that other flakes can use + outputs = { self, flake-schemas, nixpkgs }: let - forAllSystems = gen: - nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed - (system: gen nixpkgs.legacyPackages.${system}); - in { - packages = forAllSystems (pkgs: { default = pkgs.callPackage ./. { }; }); + # Helpers for producing system-specific outputs + supportedSystems = [ "aarch64-darwin" ]; + forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f { + pkgs = import nixpkgs { inherit system; }; + }); + in + { + # Schemas tell Nix about the structure of your flake's outputs + schemas = flake-schemas.schemas; + + packages = forEachSupportedSystem ({ pkgs }: { + default = pkgs.stdenv.mkDerivation { + name = "scopeddnsutil"; + src = ./.; + + # Including SwiftPM as a nativeBuildInput provides a buildPhase for you. + # This by default performs a release build using SwiftPM, essentially: + # swift build -c release + nativeBuildInputs = with pkgs; [ + swift + swiftpm + ]; + + installPhase = '' + binPath="$(swiftpmBinPath)" + mkdir -p $out/bin + cp $binPath/scopeddnsutil $out/bin/ + ''; + }; + }); - devShells = forAllSystems (pkgs: { - default = pkgs.mkShell.override { inherit (pkgs.swiftPackages) stdenv; } { - buildInputs = [ pkgs.swift pkgs.swiftpm pkgs.swiftpm2nix pkgs.swiftPackages.Foundation ]; - LD_LIBRARY_PATH = "${pkgs.swiftPackages.Dispatch}/lib"; + # Development environments + devShells = forEachSupportedSystem ({ pkgs }: { + default = pkgs.mkShell { + # Pinned packages available in the environment + packages = with pkgs; [ + nixpkgs-fmt + swift + swiftpm + swiftpm2nix + swiftPackages.Foundation + ]; }; }); }; -} \ No newline at end of file +} diff --git a/nix/default.nix b/nix/default.nix deleted file mode 100644 index 1489ecb..0000000 --- a/nix/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -# This file was generated by swiftpm2nix. -{ - workspaceStateFile = ./workspace-state.json; - hashes = { - }; -} diff --git a/nix/workspace-state.json b/nix/workspace-state.json deleted file mode 100644 index 4d652e6..0000000 --- a/nix/workspace-state.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "object": { - "artifacts": [], - "dependencies": [] - }, - "version": 6 -}