forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
74 lines (72 loc) · 1.84 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{
description = "Linux_Learner";
nixConfig.bash-prompt = "[nix(Linux_Learner)] ";
inputs = {nixpkgs.url = "github:nixos/nixpkgs/23.11";};
outputs = {
self,
nixpkgs,
} @ inputs: let
# Systems supported
allSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];
# Helper to provide system-specific attributes
forAllSystems = f:
nixpkgs.lib.genAttrs allSystems
(system: f {pkgs = import nixpkgs {inherit system;};});
in {
devShells = forAllSystems ({pkgs}: let
# Funtions targerPkgs multiPkgs (require a pkgs)
targetPkgs = pkgs:
with pkgs; [
# tools to gen prompt
ctags
bear
bison
gnumake
flex
clang-tools
ccls
llvmPackages.clang
# other
util-linux
git
bc
python3
];
multiPkgs = pkgs: with pkgs; [ncurses libelf glibc];
in {
linux_learning_fhs = let
linux_learning_env = pkgs.buildFHSUserEnv {
name = "linux_learning_fhs";
inherit targetPkgs multiPkgs;
runScript = "bash";
profile = ''
export FHS=1
'';
extraOutputsToInstall = ["dev"];
};
in
pkgs.mkShell {
name = "Linux_Learner_FHS";
buildInputs = [linux_learning_env];
shellHook = ''
echo "Welcome in $name"
exec linux_learning_fhs
'';
};
linux_learning = let
in
pkgs.mkShell {
name = "Linux_Learner";
packages = (targetPkgs pkgs) ++ (multiPkgs pkgs);
shellHook = ''
echo "Welcome in $name"
'';
};
});
};
}