Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dduan/nixswiftpm
Nix helper for SwiftPM
https://github.com/dduan/nixswiftpm
Last synced: 23 days ago
JSON representation
Nix helper for SwiftPM
- Host: GitHub
- URL: https://github.com/dduan/nixswiftpm
- Owner: dduan
- License: mit
- Created: 2022-01-30T08:37:51.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-30T08:40:00.000Z (about 3 years ago)
- Last Synced: 2025-01-11T16:35:47.970Z (about 1 month ago)
- Language: Nix
- Size: 1.95 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# nixSwiftPM
A helper for building SwiftPM projects in Nix.
For now, it builds only executable product defined in Package.swift. An example:
```nix
{ pkgs ? import { } }:
let
nixSwiftPM = import ./nixSwiftPM.nix { };
in nixSwiftPM.buildExecutableProduct {
src = ./.;
productName = "awesome-cli"; # product name as defined in Package.swift
executableName = "awesome"; # Rename the final output
}
```## FAQ
### Why not just run `swift build`?
In its current state, `nixSwiftPM` takes care of downloading source dependencies for SwiftPM according to its
Package.resolved. Each dependency is downloaded and unpacked as a Nix derivation. This way, we take advantage
of Nix's caching mechanism, leading us one step closer to hermetic build output.### Does that mean Package.resolved must be present?
Yes.
### What's the build setting?
By default, the target is built in release configuration. You can change that to `debug` with the
`buildConfig` argument. Additional arguments for `swift build` can be passed by `additionalFlags`.### What if I need more build time or runtime dependencies?
You can pass in additional `nativeBuildInputs` and/or `buildInputs` in the argument set.
### How about the final output?
By default, the built executable is placed in `$out/bin/`. You may completely override the `installPhase` as
you see fit.