nix: Replace flake-utils with flake-part

This commit is contained in:
Sameer Rahmani 2024-04-10 14:32:36 +01:00
parent e39d538e9b
commit fce6134cac
Signed by: lxsameer
GPG Key ID: 8741FACBF412FFA5
4 changed files with 186 additions and 154 deletions

View File

@ -23,7 +23,7 @@
},
"emacs-overlay_2": {
"inputs": {
"flake-utils": "flake-utils_3",
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_3",
"nixpkgs-stable": "nixpkgs-stable_2"
},
@ -42,6 +42,42 @@
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1712014858,
"narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "9126214d0a59633752a136528f5f3b9aa8565b7d",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-parts_2": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib_2"
},
"locked": {
"lastModified": 1712014858,
"narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "9126214d0a59633752a136528f5f3b9aa8565b7d",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
@ -64,24 +100,6 @@
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
@ -96,24 +114,6 @@
"type": "github"
}
},
"flake-utils_4": {
"inputs": {
"systems": "systems_4"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1707689078,
@ -130,6 +130,42 @@
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"dir": "lib",
"lastModified": 1711703276,
"narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d8fe5e6c92d0d190646fb9f1056741a229980089",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib_2": {
"locked": {
"dir": "lib",
"lastModified": 1711703276,
"narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d8fe5e6c92d0d190646fb9f1056741a229980089",
"type": "github"
},
"original": {
"dir": "lib",
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1707650010,
@ -213,20 +249,20 @@
"noether": {
"inputs": {
"emacs-overlay": "emacs-overlay_2",
"flake-utils": "flake-utils_4",
"flake-parts": "flake-parts_2",
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1712346647,
"narHash": "sha256-flVg6BjO8umCjYpjRhCmvXeJxF7OoQ+bdh1ZZt2gvUM=",
"lastModified": 1712755154,
"narHash": "sha256-ilCQqdi203dGpAhEh6EBL5Foxo2Bxu/Vhbz+0NBNmIc=",
"ref": "refs/heads/main",
"rev": "17e766cb320eea770ae169745d2e47bfbe80fdfe",
"revCount": 45,
"rev": "e6f3fd58ab283867733e940d1287923e6f0efae4",
"revCount": 46,
"type": "git",
"url": "https://devheroes.codes/lxsameer/noether"
},
"original": {
"rev": "17e766cb320eea770ae169745d2e47bfbe80fdfe",
"rev": "e6f3fd58ab283867733e940d1287923e6f0efae4",
"type": "git",
"url": "https://devheroes.codes/lxsameer/noether"
}
@ -234,7 +270,7 @@
"root": {
"inputs": {
"emacs-overlay": "emacs-overlay",
"flake-utils": "flake-utils_2",
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs_2",
"noether": "noether"
}
@ -268,36 +304,6 @@
"repo": "default",
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_4": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",

View File

@ -17,18 +17,19 @@
description = "FG42 - Emacs Editor for advance users";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/442d407992384ed9c0e6d352de75b69079904e4e";
inputs.noether.url = "git+https://devheroes.codes/lxsameer/noether?rev=17e766cb320eea770ae169745d2e47bfbe80fdfe";
inputs.noether.url = "git+https://devheroes.codes/lxsameer/noether?rev=e6f3fd58ab283867733e940d1287923e6f0efae4";
inputs.emacs-overlay.url = "github:nix-community/emacs-overlay/0f7f3b39157419f3035a2dad39fbaf8a4ba0448d";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
outputs = { self, nixpkgs, ... }@inputs:
inputs.flake-utils.lib.eachDefaultSystem (system:
outputs = { self, nixpkgs, flake-parts, ... }@inputs: flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"aarch64-darwin"
"riscv64-linux"
"x86_64-linux"
];
perSystem = { config, self', inputs', pkgs, system, ... }:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ inputs.emacs-overlay.overlays.package ];
};
test-x = pkgs.writeShellApplication {
name = "test-x";
runtimeInputs = [ pkgs.xorg.xorgserver ];
@ -37,54 +38,23 @@
${pkgs.xorg.xorgserver.out}/bin/Xephyr -br -ac -noreset -screen 800x600 :1
'';
};
lemacs = pkgs.emacs29.override {
withTreeSitter = true;
} // (pkgs.lib.optionalAttrs (pkgs.stdenv.isLinux) {
noether = inputs.noether.outputs.packages.${system}.default;
factory = params: pkgs.callPackage ./nix/factory.nix ({ inherit noether; } // params);
default = (factory {});
in {
packages = {
default = default.fg42;
} // (pkgs.lib.optionalAttrs (system == "x86_64-linux") {
# Gtk causes a flickering issue on WM mode
withGTK3 = false;
toolkit = "lucid";
wm = (factory { emacsParams.toolkit = "lucid"; }).fg42;
motif = (factory { emacsParams.toolkit = "motif"; }).fg42;
});
elispDepsFile = ./lisp/fg42/deps.el;
elispPkgs = pkgs.callPackage ./nix/deps.nix {
inherit elispDepsFile;
};
ourPackages = {
noether-mode = inputs.noether.outputs.packages.${system}.default;
};
fg42 = pkgs.callPackage ./nix/fg42.nix {
inherit elispPkgs ourPackages;
srcDir = ./.;
emacs = lemacs;
};
run-test-wm = pkgs.writeShellApplication {
name = "run-test-wm";
runtimeInputs = [ fg42 ];
text = ''
DISPLAY=:1 ${fg42}/bin/fg42-wm
'';
};
in {
inherit pkgs;
packages.default = fg42;
packages.${system}.default = fg42;
devShells.default = pkgs.mkShell {
nativeBuildInputs = [ fg42 pkgs.fish test-x run-test-wm ];
buildInputs = [ fg42 ];
# shellHook = ''
# fish && exit
# '';
nativeBuildInputs = [ default.fg42 pkgs.fish test-x default.run-test-wm ];
buildInputs = [ default.fg42 ];
};
}
);
};
};
}

50
nix/factory.nix Normal file
View File

@ -0,0 +1,50 @@
# Fg42 - Emacs Editor for advance users
#
# Copyright (c) 2010-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{ lib, stdenv, emacs29, callPackage, writeShellApplication, noether
, emacsParams ? {},
fg42Params ? {}
} :
let
lemacs = emacs29.override {
withTreeSitter = true;
} // emacsParams;
elispDepsFile = ../lisp/fg42/deps.el;
elispPkgs = callPackage ./deps.nix {
inherit elispDepsFile;
};
ourPackages = {
noether-mode = noether;
};
fg42 = callPackage ./fg42.nix ({
inherit elispPkgs ourPackages;
srcDir = ../.;
emacs = lemacs;
} // fg42Params);
run-test-wm = writeShellApplication {
name = "run-test-wm";
runtimeInputs = [ fg42 ];
text = ''
DISPLAY=:1 ${fg42}/bin/fg42-wm
'';
};
in { inherit fg42 run-test-wm; }

View File

@ -18,17 +18,17 @@
, nil, # nix lsp server
# python deps
python311, python3Packages,
# This is a set of system tools required for FG42
# to work.
pyright, emacs, ripgrep, git, texinfo, vazir-fonts, fira-code, nerdfonts
# python deps
python311, python3Packages,
# This is a set of system tools required for FG42
# to work.
pyright, emacs, ripgrep, git, texinfo, vazir-fonts, fira-code, nerdfonts
, fira-mono, noto-fonts, gcc, ltex-ls, bash, tree-sitter, fd
, aspellWithDicts,
supportWM ? true, xorg, slock,
supportWM ? true, xorg, slock,
supportPython ? true, supportVerilog ? true, svls, verilator, }:
supportPython ? true, supportVerilog ? true, svls, verilator, }:
with builtins;
let
version = "4.0.0";
@ -43,26 +43,32 @@ let
dicts = aspellWithDicts (dicts: with dicts; [ en en-computers en-science ]);
runtimeBins = [ ripgrep git ltex-ls tree-sitter direnv nix nil dicts fd ]
++ (lib.optional supportPython [
python311
# Python deps
python311
pyright
runtimeBins = [
ripgrep git tree-sitter direnv nix nil dicts fd
]
++ (lib.optional (!stdenv.buildPlatform.isRiscV) [
# Not supported on Risc-V
ltex-ls
])
++ (lib.optional supportPython [
python311
# Python deps
python311
pyright
python3Packages.black
python3Packages.pylint
python3Packages.flake8
]) ++ (lib.optional supportVerilog [ svls ])
++ (lib.optional (supportVerilog && stdenv.isLinux) [
# SystemC is required by verilator that at the
# moment is only available on Linux
verilator
]) ++ (lib.optional (supportWM && stdenv.isLinux) [
# Window manager supports works on Linux only
xorg.xhost
slock
]);
python3Packages.black
python3Packages.pylint
python3Packages.flake8
]) ++ (lib.optional supportVerilog [ svls ])
++ (lib.optional (supportVerilog && stdenv.isLinux) [
# SystemC is required by verilator that at the
# moment is only available on Linux
verilator
]) ++ (lib.optional (supportWM && stdenv.isLinux) [
# Window manager supports works on Linux only
xorg.xhost
slock
]);
paths = map (x: "${x}/bin/") (lib.lists.flatten runtimeBins);
pathsStr = lib.strings.concatStrings (lib.strings.intersperse ":" paths);