even more stuffs for top-level nix-flake

top-level-nix
Pegasust 2022-12-25 03:54:10 -07:00
parent 9b0a54e534
commit 93e5306ce3
9 changed files with 272 additions and 32 deletions

1
default.nix Normal file
View File

@ -0,0 +1 @@
# We use top-level nix-flake, so default.nix is basically just a wrapper around ./flake.nix

20
dev-shell.nix Normal file
View File

@ -0,0 +1,20 @@
# Ideally, this should contain the barebone necessary for building/interacting
# with tech used in this project
# Should also incorporate shortcuts like scripts/{hm-switch,conf-sysnix}.sh in here instead
# It should not contain PDE
{pkgs? import <nixpkgs> {}
,lib
,...}: pkgs.mkShell {
# mkShell doesn't care about the differences across nativeBuildInputs,
# buildInputs, or packages
buildInputs = [
# shell scripts
(lib.shellAsDrv {script = ''echo "hello world"''; pname = "hello";})
];
# env vars
lol="hello world";
}

View File

218
flake.lock Normal file
View File

@ -0,0 +1,218 @@
{
"nodes": {
"agenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1665870395,
"narHash": "sha256-Tsbqb27LDNxOoPLh0gw2hIb6L/6Ow/6lIBvqcHzEKBI=",
"owner": "ryantm",
"repo": "agenix",
"rev": "a630400067c6d03c9b3e0455347dc8559db14288",
"type": "github"
},
"original": {
"owner": "ryantm",
"repo": "agenix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1668681692,
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "009399224d5e398d03b22badca40a37ac85412a1",
"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": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"utils": "utils"
},
"locked": {
"lastModified": 1671958483,
"narHash": "sha256-wX+VBdHwrpW654PzmM4efiPdUDI8da8TGZeQt/zYP40=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "939731b8cb75fb451170cb8f935186a6a7424444",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixgl": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1661367362,
"narHash": "sha256-Qc8MXcV+YCPREu8kk6oggk23ZBKLqeQRAIsLbHEviPE=",
"owner": "guibou",
"repo": "nixGL",
"rev": "7165ffbccbd2cf4379b6cd6d2edd1620a427e5ae",
"type": "github"
},
"original": {
"owner": "guibou",
"repo": "nixGL",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1660551188,
"narHash": "sha256-a1LARMMYQ8DPx1BgoI/UN4bXe12hhZkCNqdxNi6uS0g=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "441dc5d512153039f19ef198e662e4f3dbb9fd65",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1671722432,
"narHash": "sha256-ojcZUekIQeOZkHHzR81st7qxX99dB1Eaaq6PU5MNeKc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "652e92b8064949a11bc193b90b74cb727f2a1405",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1665296151,
"narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "14ccaaedd95a488dd7ae142757884d8e125b3363",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"agenix": "agenix",
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"home-manager": "home-manager",
"nixgl": "nixgl",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils_3",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1671935094,
"narHash": "sha256-fWEkH5550R6q6+CeG/317g9ywE/ZhW/4zuCjTaDsHe8=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "fd2740316bacb3e0106381c325e0bb90d6790aeb",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@ -36,12 +36,12 @@
# inject nixpkgs.lib onto c_ (calculus) # inject nixpkgs.lib onto c_ (calculus)
_lib = pkgs.lib; _lib = pkgs.lib;
inputs = (lib.recursiveUpdate {inherit system, }) inputs = (_lib.recursiveUpdate {inherit system;} _inputs);
inputs_w_pkgs = (_lib.recursiveUpdate {inherit pkgs;} inputs); inputs_w_pkgs = (_lib.recursiveUpdate {inherit pkgs;} inputs);
lib = _lib.recursiveUpdate (import ./lib inputs_w_pkgs) _lib; lib = _lib.recursiveUpdate (import ./lib inputs_w_pkgs) _lib;
# update inputs with our library and past onto our end configurations # update inputs with our library and past onto our end configurations
inputs_w_lib = (lib.recursiveUpdate lib inputs_w_pkgs); inputs_w_lib = (lib.recursiveUpdate {inherit lib;} inputs_w_pkgs);
modules = (import ./modules inputs_w_lib); modules = (import ./modules inputs_w_lib);
hosts = (import ./hosts inputs_w_lib); hosts = (import ./hosts inputs_w_lib);
users = (import ./users inputs_w_lib); users = (import ./users inputs_w_lib);
@ -50,6 +50,6 @@
in { in {
# inherit (hosts) nixosConfigurations; # inherit (hosts) nixosConfigurations;
# inherit (users) homeConfigurations; # inherit (users) homeConfigurations;
devShell = import ./shell final_inputs; devShell."${system}" = import ./shell.nix final_inputs;
}; };
} }

11
lib/default.nix Normal file
View File

@ -0,0 +1,11 @@
{pkgs,...}@inputs: let
lib = pkgs.lib;
in {
# short-hand to create a shell derivation
# NOTE: this is pure. This means, env vars from devShells might not
# be accessible unless MAYBE they are `export`ed
shellAsDrv = {script, pname}: (pkgs.callPackage (
# just a pattern that we must remember: args to this are children of pkgs.
{writeShellScriptBin}: writeShellScriptBin pname script
) {});
}

1
modules/default.nix Normal file
View File

@ -0,0 +1 @@
inputs: {}

View File

@ -15,15 +15,14 @@ let
# Yes, I desperately want neovim to work out-of-the-box without flake.nix for now # Yes, I desperately want neovim to work out-of-the-box without flake.nix for now
# I want at least python LSP to work everywhere because it's basically # I want at least python LSP to work everywhere because it's basically
# an alternative to bash script when I move to OpenColo # an alternative to bash script when I move to OpenColo
pkgs.gccStdenv # pkgs.gccStdenv
pkgs.gcc # pkgs.gcc
pkgs.tree-sitter # pkgs.tree-sitter
pkgs.ripgrep pkgs.fzf # file name fuzzy search
pkgs.fzf
# pkgs.sumneko-lua-language-server # pkgs.sumneko-lua-language-server
pkgs.ripgrep pkgs.ripgrep # content fuzzy search
pkgs.zk pkgs.zk # Zettelkasten (limited support)
pkgs.fd pkgs.fd # Required by a Telescope plugin (?)
pkgs.stdenv.cc.cc.lib pkgs.stdenv.cc.cc.lib
# Python3 as alternative to bash scripts :^) # Python3 as alternative to bash scripts :^)
# (pkgs.python310Full.withPackages (pypkgs: [ # (pkgs.python310Full.withPackages (pypkgs: [
@ -44,14 +43,14 @@ in
}; };
home.packages = pkgs.lib.unique ([ home.packages = pkgs.lib.unique ([
# pkgs.ncdu # pkgs.ncdu
pkgs.rclone pkgs.rclone # cloud file operations
pkgs.htop pkgs.htop # system diagnostics in CLI
pkgs.ripgrep pkgs.ripgrep # content fuzzy search
pkgs.unzip pkgs.unzip # compression
pkgs.zip pkgs.zip # compression
# cool utilities # cool utilities
pkgs.yq # Yaml adaptor for jq (only pretty print, little query) pkgs.yq # Yaml adaptor for jq (only pretty print, little query)
pkgs.xorg.xclock # TODO: only include if have GL # For testing GL installation pkgs.xorg.xclock # TODO: only include if have GL # For testing GL installation
pkgs.logseq # TODO: only include if have GL # Obsidian alt pkgs.logseq # TODO: only include if have GL # Obsidian alt
pkgs.mosh # Parsec for SSH pkgs.mosh # Parsec for SSH
@ -59,7 +58,7 @@ in
pkgs.lynx # Web browser at your local terminal pkgs.lynx # Web browser at your local terminal
# Personal management # Personal management
pkgs.keepass pkgs.keepass # password manager. wish there is a keepass-query
# pkgs.tailscale # VPC;; This should be installed in system-nix # pkgs.tailscale # VPC;; This should be installed in system-nix
pkgs.python310 # dev packages should be in project pkgs.python310 # dev packages should be in project
@ -76,6 +75,7 @@ in
programs.jq = { programs.jq = {
enable = true; enable = true;
}; };
# TODO: override the original package, inject tree-sitter and stuffs
programs.neovim = { programs.neovim = {
enable = true; enable = true;
viAlias = true; viAlias = true;

View File

@ -1,14 +1,3 @@
# Ideally, this should contain the barebone necessary for building/interacting # This uses the exported devShells from flake.nix
# with tech used in this project # the default or base version of nix-shell can be found in dev-shell.nix instead
# This architecture is because we use top-level flake.nix
# Should also incorporate shortcuts like scripts/{hm-switch,conf-sysnix}.sh in here instead
# It should not contain PDE
{pkgs? import <nixpkgs> {}
,...}: pkgs.mkShell {
# These are the ones that can be built by a remote machine
nativeBuildInputs = [];
# These are the ones that must be built by the target machine
lol="hello world";
}