Fixup flake.nix

Signed-off-by: magic_rb <richard@brezak.sk>
This commit is contained in:
magic_rb 2023-12-30 19:24:24 +01:00
parent 033a14fbf0
commit d704b7a023
No known key found for this signature in database
GPG key ID: 08D5287CC5DDCA0E

217
flake.nix
View file

@ -2,47 +2,93 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
org-thtml = { url = "github:MagicRB/org-thtml"; flake = false; };
emacs-htmlize = { url = "github:hniksic/emacs-htmlize"; flake = false; };
modus-themes = { url = "github:protesilaos/modus-themes"; flake = false; };
web-mode = { url = "github:fxbois/web-mode"; flake = false; };
hcl-mode = { url = "github:purcell/emacs-hcl-mode"; flake = false; };
yaml-mode = { url = "github:yoshiki/yaml-mode"; flake = false; };
nix-mode = { url = "github:NixOS/nix-mode"; flake = false; };
magit = { url = "github:magit/magit"; flake = false; };
compat = { url = "github:emacs-straight/compat"; flake = false; };
dash = { url = "github:magnars/dash.el"; flake = false; };
s-el = { url = "github:magnars/s.el"; flake = false; };
dockerfile-mode = { url = "github:spotify/dockerfile-mode"; flake = false; };
org-special-block-extras = { url = "github:alhassy/org-special-block-extras"; flake = false; };
lf = { url = "github:alhassy/lf"; flake = false; };
org-thtml = {
url = "github:MagicRB/org-thtml";
flake = false;
};
emacs-htmlize = {
url = "github:hniksic/emacs-htmlize";
flake = false;
};
modus-themes = {
url = "github:protesilaos/modus-themes";
flake = false;
};
web-mode = {
url = "github:fxbois/web-mode";
flake = false;
};
hcl-mode = {
url = "github:purcell/emacs-hcl-mode";
flake = false;
};
yaml-mode = {
url = "github:yoshiki/yaml-mode";
flake = false;
};
nix-mode = {
url = "github:NixOS/nix-mode";
flake = false;
};
magit = {
url = "github:magit/magit";
flake = false;
};
compat = {
url = "github:emacs-straight/compat";
flake = false;
};
dash = {
url = "github:magnars/dash.el";
flake = false;
};
s-el = {
url = "github:magnars/s.el";
flake = false;
};
dockerfile-mode = {
url = "github:spotify/dockerfile-mode";
flake = false;
};
org-special-block-extras = {
url = "github:alhassy/org-special-block-extras";
flake = false;
};
lf = {
url = "github:alhassy/lf";
flake = false;
};
};
outputs = { self
, nixpkgs
, nixng
, org-thtml
, emacs-htmlize
, modus-themes
, web-mode
, hcl-mode
, yaml-mode
, nix-mode
, magit
, compat
, dash
, s-el
, dockerfile-mode
, org-special-block-extras
, lf
, ...
}@inputs:
let
inherit (nixpkgs.lib)
outputs = {
self,
nixpkgs,
nixng,
org-thtml,
emacs-htmlize,
modus-themes,
web-mode,
hcl-mode,
yaml-mode,
nix-mode,
magit,
compat,
dash,
s-el,
dockerfile-mode,
org-special-block-extras,
lf,
...
} @ inputs: let
inherit
(nixpkgs.lib)
genAttrs
concatMapStringsSep;
concatMapStringsSep
fix
getExe
;
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
supportedSystems = ["x86_64-linux" "i686-linux" "aarch64-linux"];
forAllSystems = f: genAttrs supportedSystems (system: f system);
packages = [
"modus-themes"
@ -66,20 +112,20 @@
(if (file-exists-p "${inputs.${x}}/lisp")
(add-to-list 'load-path "${inputs.${x}}/lisp")
(add-to-list 'load-path "${inputs.${x}}"))
'') packages)
+
"\n"
+
(concatMapStringsSep "\n" (x: ''
'')
packages)
+ "\n"
+ (concatMapStringsSep "\n" (x: ''
(when (string-match-p "^.*-mode$" "${x}")
(require '${x}))
'') packages));
'')
packages));
site = pkgs: which:
pkgs.stdenv.mkDerivation {
name = which;
version = "0.1";
src = ./.;
nativeBuildInputs = [ pkgs.utillinux pkgs.emacs ];
nativeBuildInputs = [pkgs.utillinux pkgs.emacs];
# xvfb-run -s '-screen 0 800x600x24' make test
buildPhase = ''
@ -104,39 +150,22 @@
cp -r public_html/* $out
'';
};
in
{
redalder = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
in
site pkgs "redalder.org"
);
in {
apps = forAllSystems (
system: let
pkgs = import nixpkgs {inherit system;};
in {
live-server = {
type = "app";
program = toString (pkgs.writeShellScript "live-server.sh" ''
nix build .#
${getExe pkgs.nodePackages.live-server} result/redalder "$@"
'');
};
nixng = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
in
site pkgs "nixng.org"
);
website = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
in
pkgs.runCommandNoCC "website" {}
''
mkdir -p $out/
ln -s ${self.redalder.${system}} $out/redalder
ln -s ${self.nixng.${system}} $out/nixng
''
);
generateCss = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
script = pkgs.writeText "init.el"
generateCSS = let
script =
pkgs.writeText "init.el"
''
(load-file "${loadPackages pkgs}")
@ -157,7 +186,9 @@
(kill-emacs)
'';
in
in {
type = "app";
program = toString (
pkgs.writeShellScript "generate-css"
''
export PATH=$PATH:${pkgs.emacs}/bin
@ -170,18 +201,38 @@
rm -r $TMPDIR
''
);
defaultPackage = forAllSystems (system:
self.website.${system}
};
}
);
devShells = forAllSystems (system:
let pkgs = import nixpkgs { inherit system; };
packages = forAllSystems (
system: let
pkgs = import nixpkgs {inherit system;};
in
{
fix (this: {
redalder = site pkgs "redalder.org";
nixng = site pkgs "nixng.org";
website =
pkgs.runCommandNoCC "website" {}
''
mkdir -p $out/
ln -s ${this.redalder} $out/redalder
ln -s ${this.nixng} $out/nixng
'';
default = this.website;
})
);
devShells = forAllSystems (
system: let
pkgs = import nixpkgs {inherit system;};
in {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
httplz
alejandra
];
};
}