Skip to content

Commit

Permalink
Optimize NixOS-WSL
Browse files Browse the repository at this point in the history
  • Loading branch information
573 committed Nov 8, 2024
1 parent 6a97c37 commit dda74d9
Show file tree
Hide file tree
Showing 10 changed files with 755 additions and 650 deletions.
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

135 changes: 69 additions & 66 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
nixos-2211-small.url = "github:NixOS/nixpkgs/nixos-22.11-small";
nixos-2311.url = "github:NixOS/nixpkgs/nixos-23.11";

deploy-rs = {
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs = {
flake-compat.follows = "flake-compat";
Expand Down Expand Up @@ -435,11 +435,10 @@ deploy-rs = {
};

outputs =
{
self,
nixpkgs,
nix-formatter-pack,
...
{ self
, nixpkgs
, nix-formatter-pack
, ...
}@inputs:
let
rootPath = self;
Expand Down Expand Up @@ -484,7 +483,7 @@ deploy-rs = {
{
inherit
inputs
rootPath # specialArgs
rootPath# specialArgs
forEachSystem
;
#inherit (nixpkgs.pkgs.stdenv.hostPlatform) system;
Expand Down Expand Up @@ -564,24 +563,28 @@ deploy-rs = {
});
in
{
/* deploy.nodes.sams9 = {
/* deploy.nodes.sams9 = {
hostname = "localhost";
profiles.system = {
user = "nix-on-droid";
sshUser = "nix-on-droid";
sshUser = "nix-on-droid";
path = inputs.deploy-rs.lib.x86_64-linux.activate.custom inputs.latest.legacyPackages.aarch64-linux.hello "./bin/hello";
};
}; */

# nix shell nixpkgs#deploy-rs --command deploy -s .#sams9 -- --impure
deploy.nodes = listToAttrs [
(mkDeploy "aarch64-linux" "sams9__aarch64-linux")
(mkDeploy "aarch64-linux" "sams9__x86_64-linux")
];
deploy = {
autoRollback = false;
magicRollback = true;
nodes = listToAttrs [
(mkDeploy "aarch64-linux" "sams9__aarch64-linux")
(mkDeploy "aarch64-linux" "sams9__x86_64-linux")
];
};

homeConfigurations = listToAttrs [
/**
calls `mkHome` as defined in ./flake/default.nix (`[system]` and `[name]` parameters) and ./flake/builders/mkHome.nix, latter the place where `extraSpecialArgs` would also go
calls `mkHome` as defined in ./flake/default.nix (`[system]` and `[name]` parameters) and ./flake/builders/mkHome.nix, latter the place where `extraSpecialArgs` would also go
*/
(mkHome "aarch64-linux" "u0_a210@localhost")
(mkHome "x86_64-linux" "dani@maiziedemacchiato")
Expand Down Expand Up @@ -660,26 +663,26 @@ deploy-rs = {
'';
path =
pkgs:
with pkgs;
(map (x: "${x.custom.programs.neovim.lightweight.outPath}") (
(
let
inherit (pkgs.stdenv) isLinux isx86_64;
in
lib.optionals (isLinux && isx86_64) [
self.nixosConfigurations.DANIELKNB1.config.home-manager.users.nixos
self.homeConfigurations."dani@maiziedemacchiato".config
]
)
++ (
let
inherit (pkgs.stdenv) isLinux isAarch64;
in
lib.optionals (isLinux && isAarch64) [
self.nixOnDroidConfigurations.sams9.config.home-manager.config
]
)
));
with pkgs;
(map (x: "${x.custom.programs.neovim.lightweight.outPath}") (
(
let
inherit (pkgs.stdenv) isLinux isx86_64;
in
lib.optionals (isLinux && isx86_64) [
self.nixosConfigurations.DANIELKNB1.config.home-manager.users.nixos
self.homeConfigurations."dani@maiziedemacchiato".config
]
)
++ (
let
inherit (pkgs.stdenv) isLinux isAarch64;
in
lib.optionals (isLinux && isAarch64) [
self.nixOnDroidConfigurations.sams9.config.home-manager.config
]
)
));
})

({
Expand All @@ -691,7 +694,7 @@ deploy-rs = {
{
program = builtins.toString (
pkgs.writeShellScript "testnixvim" ''
${self.inputs.nixvim.packages."${system}".default}/bin/nvim
${self.inputs.nixvim.packages."${system}".default}/bin/nvim
''
);
type = "app";
Expand All @@ -705,26 +708,26 @@ deploy-rs = {
'';
path =
pkgs:
with pkgs;
(map (x: "${x.custom.programs.emacs.finalPackage.outPath}") (
(
let
inherit (pkgs.stdenv) isLinux isx86_64;
in
lib.optionals (isLinux && isx86_64) [
self.nixosConfigurations.DANIELKNB1.config.home-manager.users.nixos
self.homeConfigurations."dani@maiziedemacchiato".config
]
)
++ (
let
inherit (pkgs.stdenv) isLinux isAarch64;
in
lib.optionals (isLinux && isAarch64) [
self.nixOnDroidConfigurations.sams9.config.home-manager.config
]
)
));
with pkgs;
(map (x: "${x.custom.programs.emacs.finalPackage.outPath}") (
(
let
inherit (pkgs.stdenv) isLinux isx86_64;
in
lib.optionals (isLinux && isx86_64) [
self.nixosConfigurations.DANIELKNB1.config.home-manager.users.nixos
self.homeConfigurations."dani@maiziedemacchiato".config
]
)
++ (
let
inherit (pkgs.stdenv) isLinux isAarch64;
in
lib.optionals (isLinux && isAarch64) [
self.nixOnDroidConfigurations.sams9.config.home-manager.config
]
)
));
})

(mkApp system "nixos-shell" {
Expand Down Expand Up @@ -769,9 +772,9 @@ deploy-rs = {
// {
nilApp = null;
}
#// {
#// {
# deploy-rs = inputs.deploy-rs.apps.${system}.default;
#}
#}
);

checks = forEachSystem (system: {
Expand All @@ -786,18 +789,18 @@ deploy-rs = {
buildInputs = [ pkgs.git self.nixosConfigurations.DANIELKNB1.pkgs.neovim ];
} ''
mkdir -p "$out"
mkdir -p "$out"
# prevent E886 ('/home-shelter' error)
export HOME=$TMPDIR
# presumes prior devenv shell run in ~/debugpy-devshell/, https://github.com/mfussenegger/nvim-dap-python/blob/408186a/README.md#debugpy
export VIRTUAL_ENV=/home/dkahlenberg/debugpy-devshell/.devenv/state/venv
nvim --headless +":scriptnames | q" 2> "$out/nvim.log"
export HOME=$TMPDIR
# presumes prior devenv shell run in ~/debugpy-devshell/, https://github.com/mfussenegger/nvim-dap-python/blob/408186a/README.md#debugpy
export VIRTUAL_ENV=/home/dkahlenberg/debugpy-devshell/.devenv/state/venv
nvim --headless +":scriptnames | q" 2> "$out/nvim.log"
if [ -n "$(cat "$out/nvim.log")" ]; then
echo "output: "$(cat "$out/nvim.log")""
exit 1
fi
echo "output: "$(cat "$out/nvim.log")""
exit 1
fi
'';
*/
});
Expand Down Expand Up @@ -876,7 +879,7 @@ deploy-rs = {
cljShell = inputs.clojure-dev-template.devShells.${system}.default;
ocamlShell = inputs.ocaml-dev-template.devShells.${system}.default;
nixdShell = inputs.nixd.devShells.${system}.default;
jupyShell = inputs.ml_env.devShells.${system}.default;
jupyShell = inputs.ml_env.devShells.${system}.default;
}
*/
);
Expand Down
29 changes: 14 additions & 15 deletions flake/builders/mkDeploy.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
inputs,
rootPath,
system,
pkgsFor,
name,
...
{ inputs
, rootPath
, system
, pkgsFor
, name
, ...
}:

let
Expand All @@ -15,21 +14,21 @@ let
deployerSystem = builtins.elemAt splittedName 1;

in
/**
see also ./../../lib/common-config.nix `homeManager.baseConfig.extraSpecialArgs` there and `homeManager.userConfig`
*/
/**
see also ./../../lib/common-config.nix `homeManager.baseConfig.extraSpecialArgs` there and `homeManager.userConfig`
*/



import "${rootPath}/hosts/${devicename}/deploy.nix" { inherit inputs; pkgs = pkgsFor.${system}; depPkgs = pkgsFor.${deployerSystem}; }

import "${rootPath}/hosts/${devicename}/deploy.nix" { inherit inputs; pkgs = pkgsFor.${system}; depPkgs = pkgsFor.${deployerSystem}; }


/*
{
hostname = "localhost";
profiles.system = {
profiles.system = {
user = "nix-on-droid";
sshUser = "nix-on-droid";
sshUser = "nix-on-droid";
path = inputs.deploy-rs.lib.x86_64-linux.activate.custom inputs.latest.legacyPackages.aarch64-linux.hello "./bin/hello";
};
}
Expand Down
8 changes: 4 additions & 4 deletions home/programs/helix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ in
name = "nix";
formatter.command = "nixfmt";
language-servers = [
language-server.nixd = with pkgs.nixd; [
command = "${nixd}/bin/nixd";
args = ["--inlay-hints" "--semantic-tokens"];
config.nixd.options.home-manager.expr = '(builtins.getFlake "${rootDir}").homeConfigurations.nix-on-droid.options';
# language-server.nixd = with pkgs.nixd; [
# command = "${nixd}/bin/nixd";
# args = ["--inlay-hints" "--semantic-tokens"];
# config.nixd.options.home-manager.expr = '(builtins.getFlake "${rootDir}").homeConfigurations.nix-on-droid.options';
];
}
{
Expand Down
Loading

0 comments on commit dda74d9

Please sign in to comment.