1
0
Fork 0

Refactor package includes

This commit is contained in:
Malte 2023-01-19 04:13:41 +01:00
parent 85525e9eb8
commit 775646326c
110 changed files with 126 additions and 243 deletions

10
.gitignore vendored
View file

@ -1,5 +1,7 @@
/configuration.nix
/.pre-commit-config.yaml
/result
/result-?
/.direnv
**/flake.lock
!/flake.lock
.pre-commit-config.yaml
result
result-?
.direnv

View file

@ -1,2 +0,0 @@
{pkgs ? import (import ../../nix/sources.nix).nixos-unstable {}}:
pkgs.haskellPackages.callCabal2nix "logfeed" ./. {}

View file

@ -1,81 +0,0 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"id": "flake-utils",
"type": "indirect"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1667639549,
"narHash": "sha256-frqZKSG/933Ctwl9voSZnXDwo8CqddXcjQhnCzwNqaM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cae3751e9f74eea29c573d6c2f14523f41c2821a",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1667680128,
"narHash": "sha256-bnXYCDzkviKNeYwnh3YW2HpgSgUMnSGVsTtHNLXBXfE=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "b84548575a627cad3e0b31b2c2b64eb7774c24db",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
}
},
"root": "root",
"version": 7
}

View file

@ -1,83 +0,0 @@
{
description = "nixpkgs-bot";
inputs = {
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = {
self,
nixpkgs,
flake-utils,
pre-commit-hooks,
...
}:
flake-utils.lib.eachSystem ["x86_64-linux"] (
system: let
ghc-version = "90";
inherit (nixpkgs.legacyPackages.${system}) lib haskell pkgs;
hlib = haskell.lib.compose;
inherit (hlib) doJailbreak dontCheck markUnbroken appendPatch;
haskellPackages = haskell.packages."ghc${ghc-version}".override {
overrides = final: prev: {
matrix-client =
appendPatch (pkgs.fetchpatch {
url = "https://github.com/softwarefactory-project/matrix-client-haskell/commit/97cb1918fcdf9b0249c6c8e70c7bfc664d718022.patch";
sha256 = "sha256-YyxgfNO5RtqpKJ9UOYPlRple0FuNmjAB1iy9vYy0HOE=";
relative = "matrix-client";
})
prev.matrix-client;
aeson-schemas = markUnbroken (dontCheck prev.aeson-schemas);
};
};
cleanSelf = lib.sourceFilesBySuffices self [
".hs"
".cabal"
"LICENSE"
"CHANGELOG.md"
];
in rec {
packages = {
default =
lib.pipe {}
[
(haskellPackages.callCabal2nix "nixpkgs-bot" cleanSelf)
haskellPackages.buildFromCabalSdist
hlib.justStaticExecutables
];
};
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra.enable = true;
statix.enable = true;
cabal-fmt.enable = true;
shellcheck.enable = true;
fourmolu.enable = true;
};
};
};
devShells.default = haskellPackages.shellFor {
packages = _: [packages.default];
buildInputs = [
pre-commit-hooks.defaultPackage.${system}
haskellPackages.haskell-language-server
haskellPackages.weeder
pkgs.haskellPackages.cabal-install
pkgs.sqlite
];
withHoogle = true;
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
}
);
}

View file

@ -1 +0,0 @@
indentation: 2

View file

@ -73,16 +73,18 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1673606088,
"narHash": "sha256-wdYD41UwNwPhTdMaG0AIe7fE1bAdyHe6bB4HLUqUvck=",
"owner": "NixOS",
"lastModified": 1673796341,
"narHash": "sha256-1kZi9OkukpNmOaPY7S5/+SlCDOuYnP3HkXHvNDyLQcc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "37b97ae3dd714de9a17923d004a2c5b5543dfa6d",
"rev": "6dccdc458512abce8d19f74195bb20fdb067df50",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {

View file

@ -1,7 +1,11 @@
{
description = "maralorns configuration";
nixConfig = {
allow-import-from-derivation = true;
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
pre-commit-hooks-nix = {
url = "github:cachix/pre-commit-hooks.nix";
@ -25,11 +29,17 @@
self',
pkgs,
config,
lib,
...
}: {
devShells.default = pkgs.mkShell {
}: let
packages = import ./packages {inherit pkgs;};
in {
devShells.default = packages.shell {
shellHook = config.pre-commit.installationScript;
};
inherit (packages) packages;
legacyPackages = {inherit (packages) haskellPackagesOverlay;};
pre-commit = {
check.enable = true;
settings = {

View file

@ -69,7 +69,7 @@ in {
xwayland
xdg_utils
libnotify
kassandra
kassandra-standalone
shotcut
audacity
paprefs

View file

@ -1,7 +1,7 @@
{pkgs, ...}: let
dhallFiles = pkgs.runCommand "kassandra-config-src" {} ''
mkdir $out
${pkgs.kassandra}/bin/kassandra2 print-types > $out/types.dhall
${pkgs.kassandra-standalone}/bin/kassandra2 print-types > $out/types.dhall
ln -s ${./kassandra}/{config,backend}.dhall $out
ln -s ${pkgs.privateFile "kassandra-uiConfig.dhall"} $out/uiConfig.dhall
'';

View file

@ -152,23 +152,26 @@ in {
lib.mkIf (!pkgs.withSecrets) {text = "echo No secrets loaded!; exit 1;";};
nix = {
settings.substituters = lib.mkAfter (
pkgs.privateValue [] "binary-caches"
# ++ (
# if config.networking.hostName != "hera" then [ "ssh-ng://nix-ssh@hera.m-0.eu?trusted=true&priority=100" ] else [ ]
# )
);
settings.trusted-public-keys = [
"nixbuild.net/maralorn-1:cpqv21sJgRL+ROaKY1Gr0k7AKolAKaP3S3iemGxK/30="
];
settings = {
substituters = lib.mkAfter (
pkgs.privateValue [] "binary-caches"
# ++ (
# if config.networking.hostName != "hera" then [ "ssh-ng://nix-ssh@hera.m-0.eu?trusted=true&priority=100" ] else [ ]
# )
);
trusted-public-keys = [
"nixbuild.net/maralorn-1:cpqv21sJgRL+ROaKY1Gr0k7AKolAKaP3S3iemGxK/30="
];
trusted-users = ["maralorn" "laminar"];
};
nixPath = ["/etc/nix-path"];
settings.trusted-users = ["maralorn" "laminar"];
buildMachines = pkgs.privateValue [] "remote-builders";
extraOptions = ''
experimental-features = nix-command flakes
fallback = true
auto-optimise-store = true
builders-use-substitutes = true
allow-import-from-derivation = true
'';
optimise = {
dates = [];

View file

@ -1,8 +0,0 @@
final: prev: let
haskellPackages = prev.haskellPackages.extend (self: super: {
kassandra = self.callCabal2nix "kassandra" ../../apps/kassandra/kassandra {};
standalone = self.callCabal2nix "standalone" ../../apps/kassandra/standalone {};
});
in {
kassandra = haskellPackages.standalone;
}

View file

@ -1,3 +0,0 @@
final: prev: {
logfeed = prev.unstableHaskellPackages.callCabal2nix "logfeed" ../../apps/logfeed {};
}

View file

@ -1,30 +0,0 @@
final: prev: let
inherit (final) lib;
inherit (final.haskell.lib.compose) justStaticExecutables dontCheck markUnbroken appendPatch;
haskellPackages = final.haskellPackages.override {
overrides = hfinal: hprev: {
matrix-client =
appendPatch (final.fetchpatch {
url = "https://github.com/softwarefactory-project/matrix-client-haskell/commit/97cb1918fcdf9b0249c6c8e70c7bfc664d718022.patch";
sha256 = "sha256-YyxgfNO5RtqpKJ9UOYPlRple0FuNmjAB1iy9vYy0HOE=";
relative = "matrix-client";
})
hprev.matrix-client;
aeson-schemas = markUnbroken (dontCheck hprev.aeson-schemas);
};
};
cleanSelf = lib.sourceFilesBySuffices ../../apps/nixpkgs-bot [
".hs"
".cabal"
"CHANGELOG.md"
"LICENSE"
];
in {
nixpkgs-bot =
lib.pipe {}
[
(haskellPackages.callCabal2nix "nixpkgs-bot" cleanSelf)
haskellPackages.buildFromCabalSdist
justStaticExecutables
];
}

1
overlays/packages.nix Normal file
View file

@ -0,0 +1 @@
_: prev: (import ../packages {pkgs = prev;}).packages

View file

@ -1,3 +0,0 @@
_: prev: {
wizards-dialog = prev.haskellPackages.callCabal2nix "wizards-dialog" ../../apps/wizards-dialog {};
}

76
packages/default.nix Normal file
View file

@ -0,0 +1,76 @@
{pkgs}: let
inherit (pkgs) lib;
inherit (pkgs.haskell.lib.compose) unmarkBroken doJailbreak dontCheck appendPatch;
includePatterns = [
".hs"
".cabal"
"LICENSE"
"CHANGELOG.md"
];
cleanCabalPackage = {
name,
source,
extraPatterns ? [],
}: hpkgs:
lib.pipe source
[
(src: lib.sourceFilesBySuffices src (includePatterns ++ extraPatterns))
(src: hpkgs.callCabal2nix name src {})
hpkgs.buildFromCabalSdist
];
haskellPackagesOverlay = final: prev:
lib.mapAttrs (_: package: package final) myHaskellPackages
// {
# For kassandra
clay = unmarkBroken (doJailbreak prev.clay);
streamly-bytestring =
unmarkBroken (dontCheck prev.streamly-bytestring);
# For nixpkgs-bot
matrix-client =
appendPatch (pkgs.fetchpatch {
url = "https://github.com/softwarefactory-project/matrix-client-haskell/commit/97cb1918fcdf9b0249c6c8e70c7bfc664d718022.patch";
sha256 = "sha256-YyxgfNO5RtqpKJ9UOYPlRple0FuNmjAB1iy9vYy0HOE=";
relative = "matrix-client";
})
prev.matrix-client;
aeson-schemas = unmarkBroken (dontCheck prev.aeson-schemas);
};
hpkgs = pkgs.haskellPackages.override {
overrides = haskellPackagesOverlay;
};
selectHaskellPackages = attrs: lib.mapAttrs (name: _: attrs.${name}) myHaskellPackages;
myHaskellPackages = {
wizards-dialog = cleanCabalPackage {
name = "wizards-dialog";
source = ./wizards-dialog;
};
logfeed = cleanCabalPackage {
name = "logfeed";
source = ./logfeed;
};
kassandra = cleanCabalPackage {
name = "kassandra";
source = ./kassandra/kassandra;
};
kassandra-standalone = cleanCabalPackage {
name = "standalone";
source = ./kassandra/standalone;
};
nixpkgs-bot = cleanCabalPackage {
name = "nixpkgs-bot";
source = ./nixpkgs-bot;
};
};
in {
packages = selectHaskellPackages hpkgs;
inherit haskellPackagesOverlay;
shell = args:
hpkgs.shellFor ({
packages = hpkgs: (builtins.attrValues (selectHaskellPackages hpkgs));
buildInputs = [
hpkgs.haskell-language-server
pkgs.cabal-install
];
}
// args);
}

Some files were not shown because too many files have changed in this diff Show more