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