Skip to content

Commit 8253ac3

Browse files
author
fidgetingbits
committed
change formals arg matching and add assert condition
1 parent 5dcb732 commit 8253ac3

File tree

4 files changed

+150
-0
lines changed

4 files changed

+150
-0
lines changed

data/playground/nix/complex.nix

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
4+
home-manager = {
5+
url = "github:nix-community/home-manager/release-23.05";
6+
inputs.nixpkgs.follows = "nixpkgs";
7+
};
8+
};
9+
10+
outputs = { self, nixpkgs, home-manager }:
11+
let
12+
mkHost = hostName: system:
13+
(({ my-config, zfs-root, pkgs, system, ... }:
14+
nixpkgs.lib.nixosSystem {
15+
inherit system;
16+
modules = [
17+
# Module 0: zfs-root and my-config
18+
./modules
19+
20+
# Module 1: host-specific config, if exist
21+
(if (builtins.pathExists
22+
./hosts/${hostName}/configuration.nix) then
23+
(import ./hosts/${hostName}/configuration.nix { inherit pkgs; })
24+
else
25+
{ })
26+
27+
# Module 2: entry point
28+
(({ my-config, zfs-root, pkgs, lib, ... }: {
29+
inherit my-config zfs-root;
30+
system.configurationRevision = if (self ? rev) then
31+
self.rev
32+
else
33+
throw "refuse to build: git tree is dirty";
34+
system.stateVersion = "23.05";
35+
imports = [
36+
"${nixpkgs}/nixos/modules/installer/scan/not-detected.nix"
37+
# "${nixpkgs}/nixos/modules/profiles/hardened.nix"
38+
# "${nixpkgs}/nixos/modules/profiles/qemu-guest.nix"
39+
];
40+
}) {
41+
inherit my-config zfs-root pkgs;
42+
lib = nixpkgs.lib;
43+
})
44+
45+
# Module 3: home-manager
46+
home-manager.nixosModules.home-manager
47+
{
48+
home-manager.useGlobalPkgs = true;
49+
home-manager.useUserPackages = true;
50+
}
51+
52+
# Module 4: config shared by all hosts
53+
(import ./configuration.nix { inherit pkgs; })
54+
];
55+
})
56+
57+
# configuration input
58+
(import ./hosts/${hostName} {
59+
system = system;
60+
pkgs = nixpkgs.legacyPackages.${system};
61+
}));
62+
in {
63+
nixosConfigurations = {
64+
exampleHost = mkHost "exampleHost" "x86_64-linux";
65+
};
66+
};
67+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
languageId: nix
2+
command:
3+
version: 6
4+
spokenForm: change arg
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: argumentOrParameter}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |-
15+
{ pkgs, ... }:
16+
{ a = 1; }
17+
selections:
18+
- anchor: {line: 0, character: 10}
19+
active: {line: 0, character: 10}
20+
marks: {}
21+
finalState:
22+
documentContents: |-
23+
:
24+
{ a = 1; }
25+
selections:
26+
- anchor: {line: 0, character: 0}
27+
active: {line: 0, character: 0}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
languageId: nix
2+
command:
3+
version: 6
4+
spokenForm: change arg
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: argumentOrParameter}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |-
15+
{ pkgs, ... }:
16+
{ a = 1; }
17+
selections:
18+
- anchor: {line: 1, character: 4}
19+
active: {line: 1, character: 4}
20+
marks: {}
21+
finalState:
22+
documentContents: |-
23+
:
24+
{ a = 1; }
25+
selections:
26+
- anchor: {line: 0, character: 0}
27+
active: {line: 0, character: 0}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
languageId: nix
2+
command:
3+
version: 6
4+
spokenForm: change condition
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: condition}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |
15+
{
16+
key = assert a > b; "foo";
17+
}
18+
selections:
19+
- anchor: {line: 1, character: 11}
20+
active: {line: 1, character: 11}
21+
marks: {}
22+
finalState:
23+
documentContents: |
24+
{
25+
key = assert ; "foo";
26+
}
27+
selections:
28+
- anchor: {line: 1, character: 15}
29+
active: {line: 1, character: 15}

0 commit comments

Comments
 (0)