style: ~apply alejandra
This commit is contained in:
@@ -26,16 +26,15 @@
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
{ lib
|
||||
, cargo-pgrx
|
||||
, pkg-config
|
||||
, rustPlatform
|
||||
, stdenv
|
||||
, Security
|
||||
, writeShellScriptBin
|
||||
{
|
||||
lib,
|
||||
cargo-pgrx,
|
||||
pkg-config,
|
||||
rustPlatform,
|
||||
stdenv,
|
||||
Security,
|
||||
writeShellScriptBin,
|
||||
}:
|
||||
|
||||
# The idea behind: Use it mostly like rustPlatform.buildRustPackage and so
|
||||
# we hand most of the arguments down.
|
||||
#
|
||||
@@ -46,33 +45,29 @@
|
||||
# If the generated rust bindings aren't needed to use the extension, its a
|
||||
# unnecessary and heavy dependency. If you set this to true, you also
|
||||
# have to add `rustfmt` to `nativeBuildInputs`.
|
||||
|
||||
{ buildAndTestSubdir ? null
|
||||
, buildType ? "release"
|
||||
, buildFeatures ? [ ]
|
||||
, cargoBuildFlags ? [ ]
|
||||
, postgresql
|
||||
# cargo-pgrx calls rustfmt on generated bindings, this is not strictly necessary, so we avoid the
|
||||
# dependency here. Set to false and provide rustfmt in nativeBuildInputs, if you need it, e.g.
|
||||
# if you include the generated code in the output via postInstall.
|
||||
, useFakeRustfmt ? true
|
||||
, usePgTestCheckFeature ? true
|
||||
, ...
|
||||
} @ args:
|
||||
let
|
||||
{
|
||||
buildAndTestSubdir ? null,
|
||||
buildType ? "release",
|
||||
buildFeatures ? [],
|
||||
cargoBuildFlags ? [],
|
||||
postgresql,
|
||||
# cargo-pgrx calls rustfmt on generated bindings, this is not strictly necessary, so we avoid the
|
||||
# dependency here. Set to false and provide rustfmt in nativeBuildInputs, if you need it, e.g.
|
||||
# if you include the generated code in the output via postInstall.
|
||||
useFakeRustfmt ? true,
|
||||
usePgTestCheckFeature ? true,
|
||||
...
|
||||
} @ args: let
|
||||
rustfmtInNativeBuildInputs = lib.lists.any (dep: lib.getName dep == "rustfmt") (args.nativeBuildInputs or []);
|
||||
in
|
||||
|
||||
assert lib.asserts.assertMsg ((args.installPhase or "") == "")
|
||||
assert lib.asserts.assertMsg ((args.installPhase or "") == "")
|
||||
"buildPgrxExtensions overwrites the installPhase, so providing one does nothing";
|
||||
assert lib.asserts.assertMsg ((args.buildPhase or "") == "")
|
||||
assert lib.asserts.assertMsg ((args.buildPhase or "") == "")
|
||||
"buildPgrxExtensions overwrites the buildPhase, so providing one does nothing";
|
||||
assert lib.asserts.assertMsg (useFakeRustfmt -> !rustfmtInNativeBuildInputs)
|
||||
assert lib.asserts.assertMsg (useFakeRustfmt -> !rustfmtInNativeBuildInputs)
|
||||
"The parameter useFakeRustfmt is set to true, but rustfmt is included in nativeBuildInputs. Either set useFakeRustfmt to false or remove rustfmt from nativeBuildInputs.";
|
||||
assert lib.asserts.assertMsg (!useFakeRustfmt -> rustfmtInNativeBuildInputs)
|
||||
"The parameter useFakeRustfmt is set to false, but rustfmt is not included in nativeBuildInputs. Either set useFakeRustfmt to true or add rustfmt from nativeBuildInputs.";
|
||||
|
||||
let
|
||||
assert lib.asserts.assertMsg (!useFakeRustfmt -> rustfmtInNativeBuildInputs)
|
||||
"The parameter useFakeRustfmt is set to false, but rustfmt is not included in nativeBuildInputs. Either set useFakeRustfmt to true or add rustfmt from nativeBuildInputs."; let
|
||||
fakeRustfmt = writeShellScriptBin "rustfmt" ''
|
||||
exit 0
|
||||
'';
|
||||
@@ -97,19 +92,24 @@ let
|
||||
pg_ctl stop
|
||||
'';
|
||||
|
||||
argsForBuildRustPackage = builtins.removeAttrs args [ "postgresql" "useFakeRustfmt" "usePgTestCheckFeature" ];
|
||||
argsForBuildRustPackage = builtins.removeAttrs args ["postgresql" "useFakeRustfmt" "usePgTestCheckFeature"];
|
||||
|
||||
# so we don't accidentally `(rustPlatform.buildRustPackage argsForBuildRustPackage) // { ... }` because
|
||||
# we forgot parentheses
|
||||
finalArgs = argsForBuildRustPackage // {
|
||||
buildInputs = (args.buildInputs or [ ]) ++ lib.optionals stdenv.hostPlatform.isDarwin [ Security ];
|
||||
finalArgs =
|
||||
argsForBuildRustPackage
|
||||
// {
|
||||
buildInputs = (args.buildInputs or []) ++ lib.optionals stdenv.hostPlatform.isDarwin [Security];
|
||||
|
||||
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [
|
||||
nativeBuildInputs =
|
||||
(args.nativeBuildInputs or [])
|
||||
++ [
|
||||
cargo-pgrx
|
||||
postgresql
|
||||
pkg-config
|
||||
rustPlatform.bindgenHook
|
||||
] ++ lib.optionals useFakeRustfmt [ fakeRustfmt ];
|
||||
]
|
||||
++ lib.optionals useFakeRustfmt [fakeRustfmt];
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
@@ -155,7 +155,7 @@ let
|
||||
RUST_BACKTRACE = "full";
|
||||
|
||||
checkNoDefaultFeatures = true;
|
||||
checkFeatures = (args.checkFeatures or [ ]) ++ (lib.optionals usePgTestCheckFeature [ "pg_test" ]) ++ [ "pg${pgrxPostgresMajor}" ];
|
||||
checkFeatures = (args.checkFeatures or []) ++ (lib.optionals usePgTestCheckFeature ["pg_test"]) ++ ["pg${pgrxPostgresMajor}"];
|
||||
};
|
||||
in
|
||||
rustPlatform.buildRustPackage finalArgs
|
||||
in
|
||||
rustPlatform.buildRustPackage finalArgs
|
||||
|
||||
133
flake.nix
133
flake.nix
@@ -60,7 +60,7 @@
|
||||
system,
|
||||
pkgs,
|
||||
}: let
|
||||
pkgs-unstable = import nixpkgs-unstable { inherit system; };
|
||||
pkgs-unstable = import nixpkgs-unstable {inherit system;};
|
||||
in {
|
||||
packages.${system} = let
|
||||
rust = {
|
||||
@@ -142,11 +142,11 @@
|
||||
shells = self.devShells.${system};
|
||||
in {
|
||||
c = pkgs.mkShell {
|
||||
buildInputs = (with pkgs; [ inotify-tools gdb gcc ]) ++ (with self.packages.${system}; [ c-hectic nvim-pager watch ]);
|
||||
buildInputs = (with pkgs; [inotify-tools gdb gcc]) ++ (with self.packages.${system}; [c-hectic nvim-pager watch]);
|
||||
PAGER = "${self.packages.${system}.nvim-pager}/bin/pager";
|
||||
};
|
||||
postgres-c = pkgs.mkShell {
|
||||
buildInputs = (with pkgs; [ inotify-tools postgresql_15 ]) ++ (with self.packages.${system}; [ nvim-pager ]) ++ (with pkgs-unstable; [ gdb gcc ]);
|
||||
buildInputs = (with pkgs; [inotify-tools postgresql_15]) ++ (with self.packages.${system}; [nvim-pager]) ++ (with pkgs-unstable; [gdb gcc]);
|
||||
PAGER = "${self.packages.${system}.nvim-pager}/bin/pager";
|
||||
|
||||
shellHook = ''
|
||||
@@ -155,7 +155,7 @@
|
||||
'';
|
||||
};
|
||||
pure-c = pkgs.mkShell {
|
||||
buildInputs = (with pkgs; [ inotify-tools ]) ++ (with self.packages.${system}; [ nvim-pager ]) ++ (with pkgs-unstable; [ gdb gcc ]);
|
||||
buildInputs = (with pkgs; [inotify-tools]) ++ (with self.packages.${system}; [nvim-pager]) ++ (with pkgs-unstable; [gdb gcc]);
|
||||
PAGER = "${self.packages.${system}.nvim-pager}/bin/pager";
|
||||
|
||||
shellHook = ''
|
||||
@@ -204,17 +204,29 @@
|
||||
modules = [
|
||||
self.nixosModules."preset.default"
|
||||
self.nixosModules."hardware.hetzner"
|
||||
({modulesPath, pkgs, ...}: {
|
||||
({
|
||||
modulesPath,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keys = [ ];
|
||||
users.users.root.openssh.authorizedKeys.keys = [];
|
||||
environment.systemPackages = with pkgs; [
|
||||
(pkgs.writers.writeMinCBin "minc-hello-world" ["<stdio.h>"] /*c*/ ''
|
||||
(pkgs.writers.writeMinCBin "minc-hello-world" ["<stdio.h>"]
|
||||
/*
|
||||
c
|
||||
*/
|
||||
''
|
||||
printf("hello world\n");
|
||||
'')
|
||||
(pkgs.writers.writeMinCBin "minc-env" ["<stdio.h>" "<stdlib.h>"] /*c*/ ''
|
||||
(pkgs.writers.writeMinCBin "minc-env" ["<stdio.h>" "<stdlib.h>"]
|
||||
/*
|
||||
c
|
||||
*/
|
||||
''
|
||||
char *env_name;
|
||||
if (argc > 1) {
|
||||
env_name = argv[1];
|
||||
@@ -228,7 +240,11 @@
|
||||
printf("Environment variable %s not found.\n", env_name);
|
||||
}
|
||||
'')
|
||||
(pkgs.writers.writeMinCBin "minc-env-check" ["<stdio.h>" "<stdlib.h>"] /*c*/ ''
|
||||
(pkgs.writers.writeMinCBin "minc-env-check" ["<stdio.h>" "<stdlib.h>"]
|
||||
/*
|
||||
c
|
||||
*/
|
||||
''
|
||||
char *env_name;
|
||||
if (argc > 1) {
|
||||
env_name = argv[1];
|
||||
@@ -257,17 +273,17 @@
|
||||
vmVariant = {
|
||||
systemd.services.fix-root-perms = {
|
||||
description = "Fix root directory permissions";
|
||||
after = [ "local-fs.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = ["local-fs.target"];
|
||||
wantedBy = ["multi-user.target"];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${pkgs.coreutils}/bin/chmod 755 /";
|
||||
};
|
||||
};
|
||||
virtualisation = {
|
||||
diskSize = 1024*6;
|
||||
diskSize = 1024 * 6;
|
||||
diskImage = null;
|
||||
forwardPorts = [ ];
|
||||
forwardPorts = [];
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -279,7 +295,10 @@
|
||||
};
|
||||
})
|
||||
];
|
||||
pkgs = import nixpkgs {inherit system; overlays = [ self.overlays.default ];};
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [self.overlays.default];
|
||||
};
|
||||
};
|
||||
})
|
||||
// {
|
||||
@@ -369,7 +388,7 @@
|
||||
overlays.default = final: prev: (
|
||||
let
|
||||
version = "1.6.1";
|
||||
pkgs-unstable = import nixpkgs-unstable { inherit (prev) system; };
|
||||
pkgs-unstable = import nixpkgs-unstable {inherit (prev) system;};
|
||||
|
||||
buildPgrxExtension =
|
||||
prev.callPackage (import (builtins.path {
|
||||
@@ -380,8 +399,7 @@
|
||||
inherit (pkgs-unstable.darwin.apple_sdk.frameworks) Security;
|
||||
};
|
||||
|
||||
buildPostgresqlExtension =
|
||||
prev.callPackage (import (builtins.path {
|
||||
buildPostgresqlExtension = prev.callPackage (import (builtins.path {
|
||||
name = "extension-builder";
|
||||
path = ./buildPostgresqlExtension.nix;
|
||||
}));
|
||||
@@ -402,7 +420,7 @@
|
||||
|
||||
inherit src postgresql;
|
||||
|
||||
buildInputs = with prev; [ openssl ];
|
||||
buildInputs = with prev; [openssl];
|
||||
|
||||
cargoHash = "sha256-AbLT7vcFV89zwZIaTC1ELat9l4UeNP8Bn9QMMOms1Co=";
|
||||
|
||||
@@ -410,7 +428,8 @@
|
||||
};
|
||||
buildPlHaskellExt = versionSuffix: let
|
||||
version = "4.0";
|
||||
in buildPostgresqlExtension {
|
||||
in
|
||||
buildPostgresqlExtension {
|
||||
postgresql = prev."postgresql_${versionSuffix}";
|
||||
} {
|
||||
pname = "plhaskell";
|
||||
@@ -439,36 +458,61 @@
|
||||
};
|
||||
in {
|
||||
hectic = self.packages.${prev.system};
|
||||
postgresql_17 = prev.postgresql_17 // {pkgs = prev.postgresql_17.pkgs // {
|
||||
postgresql_17 =
|
||||
prev.postgresql_17
|
||||
// {
|
||||
pkgs =
|
||||
prev.postgresql_17.pkgs
|
||||
// {
|
||||
http = buildHttpExt "17";
|
||||
pg_smtp_client = buildSmtpExt "17";
|
||||
plhaskell = buildPlHaskellExt "15";
|
||||
postgreact = prev.callPackage ./package/c/postgreact/default.nix { postgresql = prev.postgresql_17; };
|
||||
};};
|
||||
postgresql_16 = prev.postgresql_16 // {pkgs = prev.postgresql_16.pkgs // {
|
||||
postgreact = prev.callPackage ./package/c/postgreact/default.nix {postgresql = prev.postgresql_17;};
|
||||
};
|
||||
};
|
||||
postgresql_16 =
|
||||
prev.postgresql_16
|
||||
// {
|
||||
pkgs =
|
||||
prev.postgresql_16.pkgs
|
||||
// {
|
||||
http = buildHttpExt "16";
|
||||
pg_smtp_client = buildSmtpExt "16";
|
||||
plhaskell = buildPlHaskellExt "15";
|
||||
postgreact = prev.callPackage ./package/c/postgreact/default.nix { postgresql = prev.postgresql_16; };
|
||||
};};
|
||||
postgresql_15 = prev.postgresql_15 // {pkgs = prev.postgresql_15.pkgs // {
|
||||
postgreact = prev.callPackage ./package/c/postgreact/default.nix {postgresql = prev.postgresql_16;};
|
||||
};
|
||||
};
|
||||
postgresql_15 =
|
||||
prev.postgresql_15
|
||||
// {
|
||||
pkgs =
|
||||
prev.postgresql_15.pkgs
|
||||
// {
|
||||
http = buildHttpExt "15";
|
||||
pg_smtp_client = buildSmtpExt "15";
|
||||
plhaskell = buildPlHaskellExt "15";
|
||||
postgreact = prev.callPackage ./package/c/postgreact/default.nix { postgresql = prev.postgresql_15; };
|
||||
};};
|
||||
postgresql_14 = prev.postgresql_14 // {pkgs = prev.postgresql_14.pkgs // {
|
||||
postgreact = prev.callPackage ./package/c/postgreact/default.nix {postgresql = prev.postgresql_15;};
|
||||
};
|
||||
};
|
||||
postgresql_14 =
|
||||
prev.postgresql_14
|
||||
// {
|
||||
pkgs =
|
||||
prev.postgresql_14.pkgs
|
||||
// {
|
||||
http = buildHttpExt "14";
|
||||
pg_smtp_client = buildSmtpExt "14";
|
||||
plhaskell = buildPlHaskellExt "15";
|
||||
postgreact = prev.callPackage ./package/c/postgreact/default.nix { postgresql = prev.postgresql_14; };
|
||||
};};
|
||||
postgreact = prev.callPackage ./package/c/postgreact/default.nix {postgresql = prev.postgresql_14;};
|
||||
};
|
||||
};
|
||||
writers = let
|
||||
writeC =
|
||||
name: argsOrScript:
|
||||
if lib.isAttrs argsOrScript && !lib.isDerivation argsOrScript then
|
||||
writeC = name: argsOrScript:
|
||||
if lib.isAttrs argsOrScript && !lib.isDerivation argsOrScript
|
||||
then
|
||||
prev.writers.makeBinWriter (
|
||||
argsOrScript // {
|
||||
argsOrScript
|
||||
// {
|
||||
compileScript = ''
|
||||
# Force gcc to treat the input file as C code
|
||||
${prev.gcc}/bin/gcc -fsyntax-only -xc $contentPath
|
||||
@@ -479,7 +523,8 @@
|
||||
${prev.gcc}/bin/gcc -xc -o $out $contentPath
|
||||
'';
|
||||
}
|
||||
) name
|
||||
)
|
||||
name
|
||||
else
|
||||
prev.writers.makeBinWriter {
|
||||
compileScript = ''
|
||||
@@ -491,9 +536,10 @@
|
||||
fi
|
||||
${prev.gcc}/bin/gcc -xc -o $out $contentPath
|
||||
'';
|
||||
} name argsOrScript;
|
||||
writeMinC =
|
||||
name: includes: body:
|
||||
}
|
||||
name
|
||||
argsOrScript;
|
||||
writeMinC = name: includes: body:
|
||||
writeC name ''
|
||||
${builtins.concatStringsSep "\n" (map (h: "#include " + h) includes)}
|
||||
|
||||
@@ -501,7 +547,9 @@
|
||||
${body}
|
||||
}
|
||||
'';
|
||||
in prev.writers // {
|
||||
in
|
||||
prev.writers
|
||||
// {
|
||||
writeCBin = name: writeC "/bin/${name}";
|
||||
writeC = writeC;
|
||||
writeMinCBin = name: includes: body: writeMinC "/bin/${name}" includes body;
|
||||
@@ -513,7 +561,10 @@
|
||||
# -- For all systems --
|
||||
inherit dotEnv minorEnvironment parseEnv forAllSystemsWithPkgs forSpecSystemsWithPkgs;
|
||||
|
||||
readEnvironment = { envVarsToRead, prefix ? "" }:
|
||||
readEnvironment = {
|
||||
envVarsToRead,
|
||||
prefix ? "",
|
||||
}:
|
||||
builtins.listToAttrs
|
||||
(map (name: {
|
||||
inherit name;
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
{ stdenv, gcc, lib, bash, inotify-tools }:
|
||||
|
||||
{
|
||||
stdenv,
|
||||
gcc,
|
||||
lib,
|
||||
bash,
|
||||
inotify-tools,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "hectic";
|
||||
version = "1.0";
|
||||
src = ./.;
|
||||
doCheck = true;
|
||||
|
||||
nativeBuildInputs = [ gcc inotify-tools ];
|
||||
nativeBuildInputs = [gcc inotify-tools];
|
||||
|
||||
buildPhase = ''
|
||||
ls
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
postgresql,
|
||||
...
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "postgreact";
|
||||
version = "0.1";
|
||||
@@ -36,6 +35,6 @@ stdenv.mkDerivation {
|
||||
homepage = "https://github.com/yukkop/util.nix";
|
||||
license = licenses.mit;
|
||||
platforms = postgresql.meta.platforms;
|
||||
maintainers = with maintainers; [ ];
|
||||
maintainers = with maintainers; [];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
{ stdenv, gcc, lib, bash, c-hectic }:
|
||||
|
||||
{
|
||||
stdenv,
|
||||
gcc,
|
||||
lib,
|
||||
bash,
|
||||
c-hectic,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "prettify";
|
||||
version = "1.0";
|
||||
src = ./.;
|
||||
doCheck = false;
|
||||
|
||||
nativeBuildInputs = [ gcc c-hectic ];
|
||||
nativeBuildInputs = [gcc c-hectic];
|
||||
|
||||
buildPhase = ''
|
||||
ls
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
{ stdenv, gcc, lib, bash, gdb }:
|
||||
|
||||
{
|
||||
stdenv,
|
||||
gcc,
|
||||
lib,
|
||||
bash,
|
||||
gdb,
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
pname = "watch";
|
||||
version = "1.0";
|
||||
src = ./.;
|
||||
doCheck = false;
|
||||
|
||||
nativeBuildInputs = [ gcc gdb ];
|
||||
nativeBuildInputs = [gcc gdb];
|
||||
|
||||
buildPhase = ''
|
||||
${bash}/bin/sh ./make.sh build
|
||||
|
||||
@@ -16,7 +16,7 @@ in
|
||||
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
|
||||
buildInputs = [ postgresql_15 ];
|
||||
buildInputs = [postgresql_15];
|
||||
|
||||
doCheck = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user