Initial commit

This commit is contained in:
Tobias Berger 2024-05-03 20:16:19 +02:00
commit f06bd00211
Signed by: toby
GPG key ID: 2D05EFAB764D6A88
4 changed files with 130 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
result

48
flake.lock Normal file
View file

@ -0,0 +1,48 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1714635257,
"narHash": "sha256-4cPymbty65RvF1DWQfc+Bc8B233A1BWxJnNULJKQ1EY=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "63c3a29ca82437c87573e4c6919b09a24ea61b0f",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"treefmt-nix": "treefmt-nix"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1714058656,
"narHash": "sha256-Qv4RBm4LKuO4fNOfx9wl40W2rBbv5u5m+whxRYUMiaA=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "c6aaf729f34a36c445618580a9f95a48f5e4e03f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

73
flake.nix Normal file
View file

@ -0,0 +1,73 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
treefmt-nix,
}:
let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
];
forEachSupportedSystem =
f: nixpkgs.lib.genAttrs supportedSystems (system: f { pkgs = import nixpkgs { inherit system; }; });
in
{
formatter = forEachSupportedSystem (
{ pkgs }: (treefmt-nix.lib.evalModule pkgs ./treefmt.nix).config.build.wrapper
);
packages = forEachSupportedSystem (
{ pkgs }:
let
system-map = {
"x86_64-linux" = "amd64";
"aarch64-linux" = "arm64";
};
system = system-map.${pkgs.system};
hash-map = {
"x86_64-linux" = "sha256-kDZYBSElpNkKxx4VXNa7d3WIv4EU8jgbWh731wChueQ=";
"aarch64-linux" = "sha256-kDZYBSElpNkKxx4VXNa7d3WIv4EU8jgbWh731wChueQ=";
};
hash = hash-map.${pkgs.system};
in
{
default = pkgs.stdenv.mkDerivation rec {
pname = "spacetime-bin";
version = "v0.9.0-beta";
src = pkgs.fetchzip {
url = "https://github.com/clockworklabs/SpacetimeDB/releases/download/${version}/spacetime.linux-${system}.tar.gz";
inherit hash;
};
buildPhase = ''
ls -la
patchelf \
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath ${pkgs.stdenv.cc.cc.lib}/lib64 \
./spacetime
mkdir -p $out/bin
cp spacetime $out/bin/spacetime
'';
};
}
);
devShells = forEachSupportedSystem (
{ pkgs }:
{
default = pkgs.mkShell {
nativeBuildInputs = [ ];
buildInputs = [ ];
};
}
);
};
}

8
treefmt.nix Normal file
View file

@ -0,0 +1,8 @@
{ ... }:
{
projectRootFile = "flake.nix";
programs = {
nixfmt-rfc-style.enable = true;
rustfmt.enable = true;
};
}