Skip to content

Commit

Permalink
chore(workspace): add nix stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicegginton committed Jun 28, 2024
1 parent a279f37 commit 1a8ab14
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.build/
result
*.xcodeproj
Package.resolved
Package.resolved
22 changes: 22 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ lib, swift, swiftpm, swiftpm2nix }:

with lib.sources;

let
generated = swiftpm2nix.helpers ./nix;
in

swift.stdenv.mkDerivation rec {
pname = "nanoseconds";
version = "1.1.3";
src = cleanSource ./.;
nativeBuildInputs = [ swift swiftpm ];

configurePhase = generated.configure;

installPhase = ''
binPath="$(swiftpmBinPath)"
mkdir -p $out/lib
cp -r $binPath/* $out/lib
'';
}
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";

outputs =
{ self
, nixpkgs
, flake-utils
,
}:

with flake-utils.lib;

eachDefaultSystem (system:

let
pkgs = import nixpkgs { inherit system; };
in

{
formatter = pkgs.nixpkgs-fmt;
packages.default = pkgs.callPackage ./default.nix { };
devShells.default = pkgs.callPackage ./shell.nix { };
});
}
5 changes: 5 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file was generated by swiftpm2nix.
{
workspaceStateFile = ./workspace-state.json;
hashes = { };
}
7 changes: 7 additions & 0 deletions nix/workspace-state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"object": {
"artifacts": [],
"dependencies": []
},
"version": 6
}
12 changes: 12 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ pkgs, swift }:

pkgs.mkShell.override { inherit (swift) stdenv; }

{
buildInputs = with pkgs; [
swift
swiftPackages.Foundation
swiftpm
swiftpm2nix
];
}

0 comments on commit 1a8ab14

Please sign in to comment.