# idea for a script -rw-r--r-- 8.9 KiB View raw
                                                                                
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
18:53:12 <whereiseveryone_> PotentialUser-50: Seems like pinephone pro's specs might be better suited for Guix. I would have tested this if it weren't for my PPP being donated to The Salvation Army...
18:54:33 gnucode has joined
18:54:41 <whereiseveryone_> Can we make Guix upstream master branch an alternative to pyenv? https://github.com/pyenv/pyenv
18:55:02 <whereiseveryone_> That is, can we support as many python versions as pyenv does?
18:55:04 maxzor has quit
18:55:17 <whereiseveryone_> I think we do this for ruby currently, more or less
18:55:53 <gnucode> hello guix!
18:57:08 <singpolyma> whereiseveryone_: upstream guix thinks that guix-history channel is the answer to that
18:59:43 alextee has joined
18:59:56 <xelxebar> Speaking of guix-history, what ever became of this: https://guix.gnu.org/en/blog/2020/add-a-subcommand-showing-gnu-guix-history-of-all-packages/
19:00:09 <whereiseveryone_> shouldn't all the ruby versions go to guix-past also then?
19:00:39 <singpolyma> whereiseveryone_: I dunno. It's not my policy
19:01:04 <singpolyma> Maybe there are packages relying on specific ruby versions so they keep them for now ?
19:01:12 aknot has quit
19:01:14 <whereiseveryone_> I'd prefer to get all my history from guix's master branch but maybe I haven't warmed up to guix-past yet
19:02:04 <singpolyma> I'd also like that, but they want to be more like Debian than nix I think :) be "a distro" with a known good set that is tested together and not much else
19:02:43 <singpolyma> Which is totally valid. I'm not having, obviously the people doing most of the work get to decide :)
19:02:48 <whereiseveryone_> xelxebar: that sounds like a cool command
19:03:24 <whereiseveryone_> I'd like a `guix cat` or a `guix edit --stdout` command
19:05:08 <xelxebar> It's not great, but `EDITOR=cat guix edit` effectively achieves that.
19:05:12 <whereiseveryone_> singpolyma: Maybe become one of the people doing most of the work and then propose the idea...
19:05:29 <whereiseveryone_> xelxebar: ohhh nice hack
19:06:14 <whereiseveryone_> xelxebar: ohhh, actually that doesn't work
19:06:25 jgeerds has quit
19:06:42 <whereiseveryone_> It spits out the whole file instead of just nnn...
19:06:55 <whereiseveryone_> `EDITOR=cat guix edit nnn`
19:07:03 <whereiseveryone_> some context
19:07:26 <whereiseveryone_> I'd like it to just print out the nnn package to standard output
19:07:43 <xelxebar> Exactly. It's not precisely what you want, but you could pipe to less and then search for the string "define-public nnn"
19:08:15 <xelxebar> Which isn't what you want at all, probably :P
19:09:13 <whereiseveryone_> yup, it's not haha
19:09:21 <whereiseveryone_> but thanks for sharing that hack anyways
19:09:30 <xelxebar> What are you trying to achieve, exactly?
19:09:35 <whereiseveryone_> TIL: EDITOR=cat guix edit nnn
19:09:51 <whereiseveryone_> xelxebar: I want to print out the entire and only the nnn package
19:10:01 <whereiseveryone_> `guix cat nnn`
19:10:11 <whereiseveryone_> or `guix edit --stdout nnn`
19:10:20 <xelxebar> I mean, what are you trying to achieve with that?
19:10:22 <whereiseveryone_> returns the lines and columns for the nnn package
19:10:34 <whereiseveryone_> I use vis as my editor
19:10:43 <whereiseveryone_> so I can pipe stuff in and out of it pretty easily
19:10:52 <whereiseveryone_> sometimes I need a template for a package
19:11:03 <xelxebar> `EDITOR=vis guix edit` does'nt work as expected?
19:11:04 stikonas has quit
19:11:27 <whereiseveryone_> yup, that's what I currently have set
19:12:23 <whereiseveryone_> In vis, if I'm in another file I can pipe in the package directly where my cursor is
19:12:38 <whereiseveryone_> I think emacs can do that too and vim
19:13:36 <whereiseveryone_> so with vis open I want to do exactly the following in vis' command mode on the current line that I'm at: `:<guix cat nnn`
19:14:04 <xelxebar> I see. You're thinking of copying in the define-public form of some package as a template or something?
19:14:06 <whereiseveryone_> That would bring in the lines for the nnn package where my cursor is currently at very conveniently
19:14:17 <whereiseveryone_> xelxebar: yup yup
19:14:28 <whereiseveryone_> in one step
19:14:59 <whereiseveryone_> just run the above command mode "pipe in" command
19:15:43 <whereiseveryone_> would be cool to do the same for any other guile symbol (think language server protocol)
19:16:05 <whereiseveryone_> maybe I just need a better snippet system ha
19:16:32 <xelxebar> Yeah, that use case isn't super convincing :P
19:16:56 <whereiseveryone_> I still think there should be a `guix cat` if there's a `guix edit`
19:17:55 <whereiseveryone_> why limit it to opening a guix package in your editor but prohibit opening a package to standard output?
19:17:57 <xelxebar> EDITOR=cat achieves that already. What you're asking for is entirely different functionality that extracts just the define-public form of a package definition.
19:18:28 <whereiseveryone_> guix edit preserves the line and column number
19:18:40 <whereiseveryone_> `EDITOR=cat` does not
19:18:45 <xelxebar> It's not obvious that this would be generally helpful. The isolated definition has module dependencies, and might even be using helper functions defined earlier in the file.
19:19:18 <whereiseveryone_> I'd be happy to first just implement it and put it in a channel or library
19:19:28 <xelxebar> Yeah, I'm not entirely sure how `guix edit` is sending line number information. You should be able to grab that somehow.
19:19:28 PastaSource has quit
19:19:32 <whereiseveryone_> before considering to get upstream to adopt it
19:20:03 <whereiseveryone_> I'm just interested in making this work for my use cases and if others want it then we can upstream it
19:20:26 <whereiseveryone_> if enough people want it, I meant
19:22:20 <xelxebar> Try this: `EDITOR=echo guix edit nnn` :D
19:23:43 <xelxebar> The edit commands looks to be specifying line number in the file like `+<line-number>`. You might be able to hack something together quikly with a custome "EDITOR".
19:28:15 <whereiseveryone_> xelxebar: oh sh*t!
19:28:22 <whereiseveryone_> ` vis $(EDITOR=echo guix edit nnn)`
19:28:29 <whereiseveryone_> that's it
19:28:31 <whereiseveryone_> THNX
19:29:05 <whereiseveryone_> there's nothing like crowd debugging
19:30:15 <whereiseveryone_> `guix git log --oneline | grep msmtp` sounds cool too
19:30:29 <whereiseveryone_> now I can put that in a bash script
19:30:56 <whereiseveryone_> `... vis $(EDITOR=echo guix edit $1) ...`
19:32:02 <xelxebar> Hrm. `vis $(EDITOR=echo guix edit ...)` should be exactly the same as `EDITOR=vis guix edit`.
19:33:14 <whereiseveryone_> ha
19:33:21 <whereiseveryone_> yes I'm silly
19:33:29 <whereiseveryone_>  bat -r $(EDITOR=echo guix edit nnn)
19:38:08 <whereiseveryone_> xelxebar: what I need is to rewrite this mess somehow:
19:38:11 <whereiseveryone_> `bat -r $(EDITOR=echo guix edit nnn | awk '{print $1}'):+20 $(EDITOR=echo guix edit nnn | awk '{print $2}')`
19:38:34 <whereiseveryone_> +20 is an arbitrary number of lines after the package
19:38:46 <whereiseveryone_> not sure how to determine the package end currently
19:39:04 <whereiseveryone_> At this point I should dive into the guile code haha
19:39:50 <xelxebar> +1 for every open parens -1 for every close parens. When your sum reaches 0, you've reached the end of the s-exp
19:40:07 <whereiseveryone_> This is exactly the result I want:
19:40:09 <whereiseveryone_> ` bat -r $(EDITOR=echo guix edit nnn | awk '{print $1}'):+32 $(EDITOR=echo guix edit nnn | awk '{print $2}')`
19:40:26 <whereiseveryone_> xelxebar: makes sense
19:40:32 <whereiseveryone_> +1
19:40:57 <xelxebar> So you basically just want to feed `+n:+32 <file-name>` to your editor, right?
19:41:11 <whereiseveryone_> would you write that as a script that parses the output of `EDITOR=echo guix edit nnn`?
19:41:20 <whereiseveryone_> yup
19:41:54 <whereiseveryone_> seems like there must be a more efficient way
19:42:16 <whereiseveryone_> than parsing the result of the actual thing I should hack
19:42:30 <whereiseveryone_> but sounds like a fun exercise
19:42:45 <whereiseveryone_> and would allow me to hack it without touching guix's code
19:42:59 <xelxebar> Yeah, grabbing the entire form is good programming fun. Would be good for you to try.
19:43:01 alextee has quit
19:43:15 <whereiseveryone_> so save the output as a string?
19:43:28 <whereiseveryone_> and then parse the string?
19:44:04 <whereiseveryone_> and extract the number of lines at the end of the closing paren?
19:44:11 <xelxebar> Your input is two strings `+<n>` and `<filename>`. Your target output is a string that contains the entire `package` or `define-public` s-expr.
19:44:46 <xelxebar> of the package at that line
19:45:35 <whereiseveryone_> The part I need to compute is the offset from `+<n>` till the end of the package?
19:45:52 <whereiseveryone_> i.e. last line of the package
19:46:08 <whereiseveryone_> then insert that value in my command
19:46:33 <xelxebar> Sure, that works too.
19:46:36 <whereiseveryone_> since bat allows me to give an offset instead of exact absolute line number